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

StreamFeed.subscribe() does not return a Faye Subscription. #607

Open
skam22 opened this issue Apr 26, 2024 · 0 comments
Open

StreamFeed.subscribe() does not return a Faye Subscription. #607

skam22 opened this issue Apr 26, 2024 · 0 comments

Comments

@skam22
Copy link

skam22 commented Apr 26, 2024

export enum StreamFeedGroups {
  user = 'user',
  timeline = 'timeline',
  timeline_aggregated = 'timeline_aggregated',
  notification = 'notification',
}

const activityClient = connect(
  Config.STREAM_API_KEY,
  null,
  Config.STREAM_APP_ID,
);

const timelineFeed = activityClient.feed(
  StreamFeedGroups.timeline,
  userId,  // string
  userToken, // string
),

const Component = () => {

  useEffect(() => {
    let subscription: Subscription | null = null;

    timelineFeed.subscribe((data) => {
      console.log('New timeline data received':, data);
    }).then((fayeSubscription: Subscription) => {

      subscription = fayeSubscription;
      console.log('Timeline listener established', subscription);


        // expected object:
           type Subscription = {
             cancel: () => void;
           };
        // actual:
           undefined



    }).catch(error => {
      if (error instanceof Error) {
        console.error('Error setting up timeline listener', error)
      }
    });
   
    return () => {
      subscription?.cancel();
      subscription = null;
    }
  },[])
 
  return (
    ...
  )
}
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