Skip to content

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

@skam22

Description

@skam22
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 (
    ...
  )
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions