martyjs / marty

A Javascript library for state management in React applications
http://martyjs.org
MIT License
1.09k stars 77 forks source link

Registering stores in applications #332

Closed bigardone closed 9 years ago

bigardone commented 9 years ago

Hi! I'm upgrading to v0.10 and I have a doubt. I'm trying to register two different stores like this:

MainApplication = Marty.createApplication () ->
  @register
    stores:
      publicCalendarStore: require '../flux/stores/public_calendar_store'
      requestFormStore: require '../flux/stores/request_form_store'

But on the main container I get an error when defining the listenTo property:

module.exports = Marty.createContainer RequestForm,
  listenTo: [
    'requestFormStore'
    'publicCalendarStore'
  ]

  fetch:
    showForm: ->
      @app.stores.requestFormStore.getState().showForm

The error in console says:

Uncaught Error: Could not find the store requestFormStore

I have also tried many combinations like "stores.requestFormStore"and so, but I get constantly a similar error.

For instance, if I register different action creators under a common actionCreators key, they work fine when calling them using this.app.actionCreators.calendarActions.... so I was wondering if there's a posible issue regarding the listenTo property or I'm just doing it wrong. What do you think?

Thanks in advance!

ntkoso commented 9 years ago

https://github.com/martyjs/marty-lib/issues/7 - same issue. https://github.com/martyjs/marty-lib/pull/11 - pull request, waits to be merged.

jhollingworth commented 9 years ago

Deployed in v0.10.2