-
Notifications
You must be signed in to change notification settings - Fork 109
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
subscribe is never called with the initial value on created but not set records? #138
Comments
getRecord is async if the record isn't already loaded client side, which means you won't have the data from the server immediately afterwards when you do a subscribe( fn, true ) |
@yasserf: Yes, but shouldn't it eventually print |
This is got to do with it just being async
|
The subscribe method should print {} once the initial data comes back though. Is that not the case? |
No it's not... |
It's not async, see: https://github.com/deepstreamIO/deepstream.io-client-js/blob/master/src/record/record-handler.js#L138 It should be, at the least:
Though, that is a different issue/bug. I would also argue that this would be less confusing:
Since it would decouple the behaviour from |
The reason this is an issue for us is that we now have to use a rather silly implementation: observe (recordName, path) {
const record = ds.record.getRecord(recordName)
return Observable
.create(o => {
record.whenReady(() => {
// Since subscribe with triggerNow will not give the initial value for created but not set records...
o.next(record.get(path))
o.complete()
})
})
.concat(Observable
.create(o => {
const update = (value) => o.next(value)
record.subscribe(path, update)
return () => {
record.unsubscribe(path, update)
record.discard()
}
})
)
} |
Yup your totally right, snapshot should only be sync if ready. If you raise a bug well'll make sure to fix it for the next release. |
@yasserf: The problem is here: https://github.com/deepstreamIO/deepstream.io-client-js/blob/master/src/record/record.js#L514 If the record is created then the oldValue will be |
…value Bug/#138 initial subscribe value
e.g.
Given that records are create on
getRecord
I would expect the above code to print{}
...Or is the record state after
getRecord
something in between exists and doesn't exists?The text was updated successfully, but these errors were encountered: