Skip to content

Instantly share code, notes, and snippets.

@aakashns
Last active March 23, 2017 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aakashns/dadb81d75460d44a94a0fc41c2bd026f to your computer and use it in GitHub Desktop.
Save aakashns/dadb81d75460d44a94a0fc41c2bd026f to your computer and use it in GitHub Desktop.
Smart version of linkStoreWithDb
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