Created
May 11, 2015 11:22
-
-
Save ahomu/3ea1877a49ddf25d7f7f to your computer and use it in GitHub Desktop.
ふむーん
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src/shared/idb-store-base.ts(3,29): error TS2497: External module ''idb-wrapper'' resolves to a non-module entity and cannot be imported using this construct. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* IDBWrapper | |
*/ | |
declare class IDBWrapper { | |
constructor(options: any); | |
put(dataObj: any, success?: (id: string) => void, error?: Function): void; | |
} | |
declare module IDBWrapper { | |
} | |
declare module 'idb-wrapper' { | |
export = IDBWrapper; | |
} | |
// // class 実装の宣言 | |
// declare class IDBWrapper { | |
// constructor(options: any); | |
// put(dataObj: any, success?: (id: string) => void, error?: Function): void; | |
// } | |
// // 公開 module の 宣言 | |
// declare module 'idb-wrapper' { | |
// export = IDBWrapper; | |
// } | |
// // 公開 module の 宣言 | |
// declare module 'idb-wrapper' { | |
// export = IDBWrapper; | |
// // globalに名前をまき散らしたくなかったら(commonjsオンリーなら)declare moduleの内側に入れる | |
// class IDBWrapper { | |
// constructor(options: any); | |
// put(dataObj: any, success?: (id: string) => void, error?: Function): void; | |
// } | |
// } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///<reference path="../common.d.ts" /> | |
import * as IDBWrapper from 'idb-wrapper'; | |
import * as Rx from 'rx'; | |
export default class IDBStoreBase<T> { | |
store: IDBWrapper; | |
open() { | |
this.store = new IDBWrapper(this); | |
} | |
put(dataObj: T): Rx.Subject<string> { | |
let subject: Rx.Subject<string> = new Rx.Subject<string>(); | |
this.store.put(dataObj, (id)=> { | |
subject.onNext(id); | |
subject.onCompleted(); | |
}, (error) => { | |
subject.onError(error); | |
subject.onCompleted(); | |
}); | |
return subject; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment