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

Ability to dynamically add/remove topics to/from asyncIterator #256

Open
dimatillck opened this issue May 17, 2022 · 0 comments
Open

Ability to dynamically add/remove topics to/from asyncIterator #256

dimatillck opened this issue May 17, 2022 · 0 comments

Comments

@dimatillck
Copy link

Hi, I wonder if there is a place for such functionality in this library.
What I'm trying to achieve is to be able to do something like that:

const SOMETHING_CHANGED_TOPIC = 'something_changed';
const SOMETHING_OTHER_CHANGED_TOPIC = 'something_other_changed';

export const resolvers = {
  Subscription: {
    anythingChanged: {
      subscribe: () => {
        const asyncIterator = pubsub.asyncIterator(SOMETHING_CHANGED_TOPIC);
        
        subscribeToInternalEvent('internal_event', (event) => {
          if (event.shouldSubscribeToSomethingOther) {
            asyncIterator.subscribe(SOMETHING_OTHER_CHANGED_TOPIC);
          }

          if (event.shouldUnsubscribeFromSomethingOther) {
            asyncIterator.unsubscribe(SOMETHING_OTHER_CHANGED_TOPIC);
          }
        });

        return asyncIterator;
      },
    },
  },
}

I have some implementation of this feature and I can create a PR to continue the discussion if there is a place for this feature in this library.

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

No branches or pull requests

1 participant