Choo: subscriptions: object or array?

Created on 9 Aug 2016  Â·  7Comments  Â·  Source: choojs/choo

I'm noticing in the choo docs subscriptions is referred to as an array:

  subscriptions: [
    (send, done) => {
      setInterval(() => {
        send('app:print', { payload: 'dog?', myOtherValue: 1000 }, (err) => {
          if (err) return done(err)
        })
      }, 1000)
    }
  ]

https://github.com/yoshuawuyts/choo#subscriptions

But in the barracks docs it's a plain object with named keys:

  subscriptions: {
    emitWoofs: (send, done) => {
      // emit a woof every second
      setInterval(() =>  send('printWoofs', { woof: 'meow?' }, done), 1000)
    }
  }

https://github.com/yoshuawuyts/barracks#subscriptions

I've seen it referred to both ways -- so which should it be?

Bonus question: if subscriptions is an object, do key names have any bearing on other aspects (reducers, effects, actions)?

Most helpful comment

lol, javascript

All 7 comments

So it used to be an array, but became an object in v3. This was done for consistency and making sure the names showed up correctly in debug output. PRs to fix docs welcome! :sparkles:

wow, that's weird, i'm using an array and it still works 😨

Yep I am using an array as well and thought that was the only way

lol, javascript

think this is resolved - closing!

needs to be fixed in template-basic 😄

It should be an object (:

On Sun, Jan 15, 2017 at 12:09 AM Haroen Viaene notifications@github.com
wrote:

needs to be fixed in template-basic 😄

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/yoshuawuyts/choo/issues/217#issuecomment-272660216,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACWler8wGyvT1iljwWu7PBCK2imR7P4Kks5rSVWrgaJpZM4Jfs7X
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tornqvist picture tornqvist  Â·  4Comments

rafaismyname picture rafaismyname  Â·  6Comments

yoshuawuyts picture yoshuawuyts  Â·  5Comments

sholtomaud picture sholtomaud  Â·  4Comments

nanaian picture nanaian  Â·  5Comments