Not seeing cross tab events
nevf opened this issue · 5 comments
I'm using plain JS with CrossTabClient(). According to https://github.com/logux/logux/blob/master/3-concepts/2-action.md#adding-actions-on-the-client:
-
Cross-tab action. It sends action to all tabs in this browser.
client.log.add(action, meta)
-
Send to server. It sends action to the server and all tabs in this browser.
client.log.add(action, { sync: true })
action is: { type: 'UPDATE_NOTE', doc: noteDoc }
I've tried both of these and don't see any:
client.log.on( 'add', ( action, meta ) ..
event being emitted with action.type =='UPDATE_NOTE'
in the other Tab, only in the current Tab.
I am seeing: Logux added and cleaned UPDATE_NOTE
in the Debug console for both Tabs.
You need to use client.on
to see cross-tab actions (it is not obvious and I don’t know right now how to make API better)
@ai thanks for the quick reply, which resolved the issue Does that mean we should replace all client.log.on()
with client.on()
if we want to work across tabs? Can you include this in the docs - thanks.
@ai Thanks for updating the docs.
So where would you use client.log.on('add', fn)
in Logux client?
To be honest, I do not know the good use case for client.log.on