-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tent: Scoped stores fire different events than the regular store #95
Comments
I could reproduce the error. |
@sebbel can you try to create a test reproducing the error? Alex will be out until next week |
I'd be happy to. |
I wasn’t able to reproduce last bit:
When I run hoodie.store('person').on('remove', function(person){
console.log('remove')
})
hoodie.store('person').on('add', function(person){
console.log('add ')
})
hoodie.store('person').on('update', function(person){
console.log('update')
})
hoodie.store('person').on('change', function(event, person){
console.log('change ',event)
})
hoodie.store('person').add({
name: 'horst'
})
.then(function () {
hoodie.store('person').removeAll()
}); I get this in my console log
But no |
I did notice I was getting |
please see the discussion on the |
this should be resolved now with |
Scoped stores emit events differently than the regular store, and sometimes don't emit the correct events at all, instead only ever emitting
update
instead ofremove
, for example.The pattern seems to be that
add
andremove
are be mutually exclusive, only the first listener of the two ever works.To reproduce
In an empty directory,
npm init -y
and hit enter until done. Install the tent release:npm i hoodie --save --no-optional
. Openpackage.json
and add this into the root object:Add a
public/index.html
file that has<script src="/hoodie/client.js"></script>
in it, then start the app withnpm start -- --inMemory
Now, open the Hoodie app in an incognito browser tab and set up some listeners in the dev console, to observe that regular
store
works as expected:Then add a person:
This logs
add
andchange add
, as expected.Now reload the page, then do the same with a scoped store:
This logs
add
,update
, andchange update
, when it should logadd
andchange add
.Here's the serious bit:
If you now
hoodie.store('person').removeAll()
, noremove
event is fired at all, onlyupdate
andchange update
. If you reload the page and do everything again, but registerremove
beforeadd
, you'll getremove
,update
, andchange update
whenever you remove something, but noadd
event when you add a person, only anupdate
.The text was updated successfully, but these errors were encountered: