File tree Expand file tree Collapse file tree 3 files changed +20
-21
lines changed
Expand file tree Collapse file tree 3 files changed +20
-21
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ Based on the installation path above.
7474 import Dexie from ' dexie'
7575
7676 // Import the sync hook
77- import useSync from ' dexie-mysql-sync'
77+ import Sync from ' dexie-mysql-sync'
7878
7979 // Setup the local database
8080 // Adding $created and $deleted as index allows to query on these fields
@@ -84,7 +84,7 @@ Based on the installation path above.
8484 })
8585
8686 // Start the synchronization
87- const sync = useSync ()
87+ const sync = new Sync ()
8888 sync.add(db.tasks, ' tasks' )
8989
9090 // Export the database and sync objects
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import Dexie from 'dexie'
55import { useLiveQuery } from 'dexie-react-hooks'
66
77// Import the sync hook
8- import usesSync from 'dexie-mysql-sync'
8+ import Sync from 'dexie-mysql-sync'
99
1010// Setup the local database
1111// Adding $created and $deleted as index allows to query on these fields
@@ -16,7 +16,7 @@ db.version(1).stores({
1616} )
1717
1818// Start the synchronization
19- const sync = usesSync ( )
19+ const sync = new Sync ( )
2020sync . add ( db . tasks , 'tasks' )
2121sync . add ( db . files , 'files' )
2222
Original file line number Diff line number Diff line change @@ -10,23 +10,22 @@ import user from './user'
1010import password from './password'
1111import logout from './logout'
1212
13- function useSync ( endpoint = '/api.php' ) {
14- const localStorageUserKey = `dexie-mysql-sync > user > ${ endpoint } `
15- return {
16- endpoint,
17- localStorageUserKey,
18- api : useAPI ( endpoint ) ,
19- debug,
20- syncs : [ ] ,
21- add,
22- reset,
23- emptyTable,
24- register,
25- login,
26- user,
27- password,
28- logout
13+ export class Sync {
14+ constructor ( endpoint = '/api.php' ) {
15+ this . endpoint = endpoint
16+ this . localStorageUserKey = `dexie-mysql-sync > user > ${ endpoint } `
17+ this . syncs = [ ]
18+ this . api = useAPI ( this . endpoint )
19+ this . debug = debug
20+ this . add = add
21+ this . reset = reset
22+ this . emptyTable = emptyTable
23+ this . register = register
24+ this . login = login
25+ this . user = user
26+ this . password = password
27+ this . logout = logout
2928 }
3029}
3130
32- export default useSync
31+ export default Sync
You can’t perform that action at this time.
0 commit comments