LeanKit-Labs / lux.js

Flux-based architecture for using ReactJS at LeanKit
MIT License
114 stars 14 forks source link

Message Topic Alignment #25

Closed ifandelse closed 9 years ago

ifandelse commented 9 years ago

The topics used for lux message contracts need to be updated to more expressive (and categorizable) options.

ifandelse commented 9 years ago

I'm keeping track of lux's message contracts here as I work on this:

Description Current Topic New topic
action is dispatched (ex - by a component) action action.initiate
action coordinator telling store to handle an action dispatch.${storeNamespace} dispatch.action.${storeNamespace}
action coordinator telling store(s) they can notify listeners of state change(s) notify dispatch.action.complete
asking a specific store for its state notify.${storeNamespace} store.${storeNamespace}.getstate
store publishing it's state/changed keys notification.${storeNamespace} store.${storeNamespace}.updated
store publishing that it had no changes nochange.${storeNamespace} store.${storeNamespace}.nochange
store registering with the dispatcher register store.register
action coordinator notifying listeners of stores that are about to send notifications prenotify dispatch.action.prenotify
if any store fails in an action, action coordinator sends this failure.action action.failure

it's possible to change the action.* topics to be action.${actionName}.* - but that information has to exist in the payload already, and isn't necessarily vital to routing.

dcneiner commented 9 years ago

I think what you provided are far more clear than what is there currently. Lots of varied thoughts, but since most of this is behind the scenes anyway – I probably don't feel super strongly about any of this if you disagree:

Then all calls would be either prefixed with dispatch or store and the store handlers would all follow the convention store.${storeNamespace}.[whatever]

Some other thoughts:

I'd probably lean toward dispatcher over dispatch as the namespace. Dispatch sounds like a command, but when used for dispatch.register its clearly a namespace, but the command feel mixes messages.

Finally, store.${storeNamespace}.updated paired with .nochange seems mis-aligned somehow. Perhaps store.${storeNamespace}.change (or .changed) instead?

ifandelse commented 9 years ago

Cool - thanks @dcneiner, good thoughts. Interested to hear @arobson as well, and then I'll make another pass.