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

Using notifications inside an autorun #15

Open
andylash opened this issue Nov 14, 2014 · 1 comment
Open

Using notifications inside an autorun #15

andylash opened this issue Nov 14, 2014 · 1 comment
Labels

Comments

@andylash
Copy link
Contributor

I'm not sure that there is a solution here, but I wanted to make an issue to get comments and then to help future people. I find I'm often creating a notification on error inside an autorun. Something like this might appear in a template's rendered function:

this.autorun(function() {
  var status = doOperation();
  if (!status) {
    Notifications.error("Status failed");
  }
});

The problem is that this is that the notification insert forces this method to rerun, which isn't desired. So instead I do this:

this.autorun(function() {
  var status = doOperation();
  if (!status) {
    Tracker.nonreactive(function() {
      Notifications.error("Status failed");
    });
  }
});

I'm not sure if the library could handle this case, but it would be nice for callers if it could. Maybe it's just a doc change?

@marcodejongh
Copy link
Contributor

@andylash Sorry for the late response. The errors/succes/addNotification methods should probaply be made nonreactive.

The package only uses the client side collection to leverage Blaze for the rendering.
So the reactivity is only used internally for drawing of templates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants