Last active
March 23, 2017 13:47
-
-
Save aakashns/dadb81d75460d44a94a0fc41c2bd026f to your computer and use it in GitHub Desktop.
Smart version of linkStoreWithDb
This file contains 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
const linkStoreWithDb = (fromDb, fromStore) => { | |
return (db, store) => { | |
const unlinkFromDb = fromDb && fromDb(db, store.dispatch); | |
const unlinkFromStore = fromStore && store.subscribe(() => fromStore(store.getState, db)); | |
const unlink = () => { | |
unlinkFromDb && unlinkFromDb(); | |
unlinkFromStore && unlinkFromStore(); | |
} | |
return unlink; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment