martyjs / marty

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

What kind of object do I need to pass to listenTo object? Can I just pass a store name? #351

Closed SudoPlz closed 9 years ago

SudoPlz commented 9 years ago

In a container if I pass a string to the listenTo object, like so:

Marty.createContainer(Home, {
listenTo: 'myStore'
}

I get an error. If I require the store like so var MyStore = require('./MyStore') and pass it to listenTo like so:

Marty.createContainer(Home, {
listenTo: MyStore
}

all works well...

Can't I just pass a string like on the docs, do I have to require the object on each container?

jhollingworth commented 9 years ago

Which version of Marty are you using (console.log(Marty.version))? We've made some major changes in v0.10 so if you're using v0.9 you should look at the older docs

SudoPlz commented 9 years ago

You are correct, I'm using version 0.9.17. I don't mind updating... Let me to that right now and get back to you.

SudoPlz commented 9 years ago

After updating I'm getting the following error

throw new Error('Must specify application type');
          ^
Error: Must specify application type

which is caused by marty express since I'm using yeoman marty generators code like so:

app.use(require('marty-express')({
  marty: require('marty'),
  routes: require('../router/routes')
}));

I know I should provide application: IsomorphicApp, //required to marty express but I have NO idea where to find this IsomorphicApp object. Theres no new Marty.Application(); code in yeoman marty generators code... What to do?

SudoPlz commented 9 years ago

Ok a few hours later, after banging my head on the wall trying to study examples, I now realise that on the previous version 0.9.* there wasn't a need for new Application(); (My guess is that is because Marty was used as a singleton?) so amongst the source files I'm working with (yeoman generator files) there was no such line of code.

In the new version of Marty 0.10.* no more singletons exist therefore now I must update my app.js file to reflect that. This really confuses me though because I have to make it work with both react-router and marty-express middleware and I don't like the examples I've found till now...

IF ONLY there was Is there any human soul that has a simple working example that works with Marty.js (*LATEST* version) React-Router, express and marty-express following the code described on the docs website (and that is not a chat application)? Like a simple page with login/register buttons etc. :P

jhollingworth commented 9 years ago

Hey,

Glad you've got it working.

We do have examples of Marty working with Marty-express & react-router https://github.com/martyjs/marty-chat-example. We also have the yeoman generator which creates a project for you from scratch https://github.com/martyjs/generator-marty

Thanks

On 23 Jun 2015, at 11:40 pm, John Kokkinidis notifications@github.com wrote:

Ok a few hours later, after banging my head on the wall trying to study examples, I now realise that on the previous version 0.9.* there wasn't a need for new Application(); (perhaps this took place under the hood somewhere?) so amongst the source files I'm working with there was no such line of code.

In the new version of Marty 0.10.* no more singletons exist therefore now I must update my app.js file to reflect that. This really confuses me though because I have to make it work with both react-router and marty-express middleware and I don't like the examples I've found till now...

IF ONLY there was Is there any human soul that has a simple working example that works with Marty.js (LATEST version) React-Router, express and marty-express following the code described on the docs website (and that is not a chat application)? Like a simple page with login/register buttons etc. :P

— Reply to this email directly or view it on GitHub.

SudoPlz commented 9 years ago

Thank you for your reply, I am in fact using yeoman generator files for Marty since day one, but its outdated. It uses marty v0.9. Today I will try to strip down marty-chat-example (which I hope is up to date) and keep on working with that..!