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

children function won't rerun reactively #146

Open
Float07 opened this issue Jul 14, 2022 · 0 comments
Open

children function won't rerun reactively #146

Float07 opened this issue Jul 14, 2022 · 0 comments
Labels

Comments

@Float07
Copy link

Float07 commented Jul 14, 2022

Hello!

I've run into a problem while using this package, and I didn't understand if it was intentional or a bug. Here is a code example from the project's documentation with modified comments explaining what I noticed.

{
  find() {
      return Notifications.find();
  },
  children(parentNotification) {
    // if any field from the parentNotification changes, this function WON'T rerun
    if (parentNotification.type === 'about_post') {
      return [{
        find(notification) {
        // if any field from the parentNotification changes, this function WILL rerun
          return Posts.find(parentNotification.objectId);
        }
      }];
    }
    return [
      {
        find(notification) {
          // if any field from the parentNotification changes, this function WILL rerun
          return Comments.find(parentNotification.objectId);
        }
      }
    ]
  }
}

To exemplify this behavior, imagine the user initially subscribe to the publication and we have a notification in the database with the type field as 'about_post', so consequently, the children publication will return a cursor from the Posts collection, since the first conditional will be true.

Now imagine that, with the subscription still open, we change the type field to anything (a value that isn't 'about_post'). The find() function for that notification will rerun, but the children() won't, which means that the returned child cursor will still be from the Posts collection, and won't change to return a cursor from the Comments collection.

I would be happy to provide more details or to create an example app to show this possible bug if you think it would be helpful. Thanks for your attention :)

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