Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactiveState: add namespaces #5

Open
steph643 opened this issue Oct 13, 2015 · 6 comments
Open

ReactiveState: add namespaces #5

steph643 opened this issue Oct 13, 2015 · 6 comments

Comments

@steph643
Copy link

I would prefer to use global helpers like this:

<template name='VideoAuthor'>
  Author name is {{AppState.videoAuthor.name}}.
</template>

Otherwise I need to prefix my root path in order to avoid mix up with template helpers...

@luisherranz
Copy link
Owner

Interesting. We can add it to the initialisation options:

AppState = new MeteorFlux.AppState({ prefix: 'state' });

Would that be ok?

@steph643
Copy link
Author

That looks great.

@steph643 steph643 changed the title AppStates feature request: scoped Blaze global helpers AppState feature request: scoped Blaze global helpers Oct 15, 2015
@luisherranz luisherranz self-assigned this Oct 26, 2015
@steph643
Copy link
Author

Global helpers make sense in the case of a singleton object. So, to me, global helpers should be part of AppState, not ReactiveState.

@luisherranz
Copy link
Owner

Totally true, they should be in a different package

@steph643
Copy link
Author

Just spent 1 hour because of this. Suppose you use AppState.set('doc', object) in your code, then the following code has very unexpected results:

<template name=myTemplate1>
  {{>myTemplate2 doc=whatever}}
</template>

<!-- Args: doc -->
<template name=myTemplate2>
  <div>doc.name</div> <!-- Here doc is not the template parameter! -->
</template>

@luisherranz
Copy link
Owner

That's not because of AppState, but because of how Meteor global Template helpers work.

If you do:

Template.registerHelper('dod', function() {
  return object;
});

it will happen the same.

If you make a PR with a namespace option for ReactiveState I will accept it.

For example:

AppState = new ReactiveState({
  namespace: 'state'
});
<template name=myTemplate2>
  <div>doc.name</div> <!-- Here doc is the template parameter -->
  <div>state.doc</div> <!-- Here doc is the AppState parameter -->
</template>

@luisherranz luisherranz changed the title AppState feature request: scoped Blaze global helpers ReactiveState: add namecespaces Dec 21, 2015
@luisherranz luisherranz changed the title ReactiveState: add namecespaces ReactiveState: add namespaces Dec 21, 2015
@luisherranz luisherranz removed their assignment Dec 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants