Closed sankar-ganesh closed 7 years ago
Nope, why would you want to?
To keep multiple tabs that are open to be in sync?
Something like this should work. Requires localForage observerable and a little extension to the default adapter to start observing.
import LFAdapter from 'ember-localforage-adapter/adapters/localforage';
export default LFAdapter.extend({
startObserveringIndexDb: Ember.on('init', function () {
var observable = window.localforage.newObservable();
var subscription = observable.subscribe({
next: function(args) {
console.log('I observe everything', args);
},
error: function(err) {
console.log('Found an error!', err);
},
complete: function() {
console.log('Observable destroyed!');
}
});
})
});
I couldn't find window.localforage.newObservable
@sankar-ganesh See that link I posted in the previous message. You will need an additional library.
As these dependencies are not compatible like an addon ember build doesn't allow me to build it together with the app. By any chance, can i reload the datastore completely to get all of the latest value instead of observing it.
Why not? You can use
app.import('bower_components/x/y.js');
to import external libraries that you installed with bower.
BTW, the zen-observer and localforage-observable are not bower components either
Then copy the distributable to your vendor folder.
that's right but then it doesn't serve the deployment rules. Instead they have either served the es6 version or the dist folder which can't be used via app.import
Fair enough. Then you should create a PR that adds the feature here. I am prepared to merge it.
Is there a way I can observe to IndexDB actions like 'add', 'update', or 'delete'