Skip to content

Commit

Permalink
feat: add indexDB
Browse files Browse the repository at this point in the history
  • Loading branch information
oct16 committed Mar 9, 2020
1 parent 4a9bba2 commit 08fca40
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 7 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { record } from '@WebReplay/record'
import { replay } from '@WebReplay/player'
import { DataStore, SnapshotData } from '@WebReplay/snapshot'
import { dbPromise, SnapshotData } from '@WebReplay/snapshot'

async function start() {
const indexDB = await dbPromise

new Promise(resolve => {
const indexDB = new DataStore('wr_db', 1, 'wr_data', () => {
resolve(indexDB)
})
}).then((indexDB: DataStore) => {
record({
emitter: data => {
indexDB.add(data)
Expand All @@ -20,4 +18,6 @@ new Promise(resolve => {
})
}
}
})
}

start()
8 changes: 7 additions & 1 deletion packages/snapshot/src/store/data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SnapshotData } from '@WebReplay/snapshot'

export class DataStore {
export class IndexDBOperator {
db: IDBDatabase
DBName: string
version: number
Expand Down Expand Up @@ -59,3 +59,9 @@ export class DataStore {
}
}
}

export const dbPromise: Promise<IndexDBOperator> = new Promise(resolve => {
const indexDB = new IndexDBOperator('wr_db', 1, 'wr_data', () => {
resolve(indexDB)
})
})

0 comments on commit 08fca40

Please sign in to comment.