logux/docs

Not seeing cross tab events

nevf opened this issue · 5 comments

nevf commented

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:

  1. Cross-tab action. It sends action to all tabs in this browser.
    client.log.add(action, meta)

  2. 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.

ai commented

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)

nevf commented

@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 commented

Yeap, good idea.

I replaced client.log.on to client.on 110fec1 and added special notes f643d84

nevf commented

@ai Thanks for updating the docs.

So where would you use client.log.on('add', fn) in Logux client?

ai commented

To be honest, I do not know the good use case for client.log.on