service from documentation creates async bug at startup
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 42/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- angular, typescript
調査の方向性
README.md の Angular ストレージサービスの例から始め、そのコンストラクターの初期化を issue に示されているサービスと比較します。初期のストレージ読み取りが初期化を待機するようにドキュメントを更新し、その後、アプリの起動中にストレージへアクセスしても例が undefined を返さなくなったことを確認します。
索引モデルが issue の本文から書いたものです。
説明
From my testing of the example service in the documentation, it seems that it contains a bug.
The constructor calls init() without async (because it's not supported in a constructor):
constructor(private storage: Storage) {
this.init();
}
However, that means that if your app is relying on the storage very early on, you are going to get back undefined from a get.
For me, I have a tutorial guard set up which checks if the tutorial has been completed to decide if it should show the homepage or redirect to the tutorial slider page. It was always showing the tutorial because the result was undefined.
I've improved the service so that it takes a similar approach to the way that Ionic Storage is actually written; which is checking if the storage is initialised before trying to operate on it.
That way it can await the proper completion of the storage:
import { Injectable } from '@angular/core';
import * as CordovaSQLiteDriver from 'localforage-cordovasqlitedriver';
import { Storage } from '@ionic/storage-angular';
@Injectable({
providedIn: 'root'
})
export class StorageService {
private _storage: Storage | null = null;
constructor(private storage: Storage) {
}
async init() {
if(this._storage != null) {
return;
}
await this.storage.defineDriver(CordovaSQLiteDriver);
const storage = await this.storage.create();
this._storage = storage;
}
public async set(key: string, value: any): Promise<any> {
await this.init();
return await this._storage?.set(key, value);
}
public async get(key: string): Promise<any> {
await this.init();
return await this._storage?.get(key);
}
}
- 主要言語
- TypeScript
- スター
- 456
- フォーク
- 97
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ionic-team/ionic-storage のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
ionic-team/ionic-storage#326 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
ionic-team/ionic-storage#325 · コメント 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
ionic-team/ionic-storage#324 · コメント 4 件 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
ionic-team/ionic-storage#323 · コメント 2 件 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
ionic-team/ionic-storage#322 · コメント 1 件 · リアクション 8 件 ·
ionic-team/ionic-storage の issue をすべて見る
似ている issue
-
Bayern feature:Application ready web
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
digitalfabrik/entitlementcard#3176 ·
メンテナーはふだん 7 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
NanmiCoder/cc-haha#1533 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
🐛 Bug: Calendar work items cannot be opened on mobile対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100