Listener
The Join Stories SDK uses some listeners that are called up in standalone and thumbview mode. Use addPlayerListener method.The name of the listeners is present in the variable listener
JoinStories.addPlayerListener(({listener: newListener, state: newState})
onStoryLoaded
This listener called when a story has been loaded into the player. Only standalone mode
onStoryFetchError
This listener is called in if there is a problem getting the stories.
onStoryFetchEmpty
The listener called when the list of stories is empty
onStoryFetchSuccess
The listener called when fetch data is successful
onStoryLinkClick
The listener called when link (no http/https) is clicked
onStoryDismissed
The listener called when the player disappears. There are 2 received parameters:
- auto : the player disappears automatically when there are no more stories to view
- manual : the player disappears manually via a user gesture (swipe, back, click on the cross, etc.)
The parameter is present in the variable state. Only standalone mode
Example
import { JoinStories } from "@join-stories/react-native-widgets";
const playerListener = JoinStories.addPlayerListener(({listener: newListener, state: newState}) => {
switch(newListener) {
case "onStoryLoaded": {
...
break;
}
case "onStoryFetchError": {
...
break;
}
case "onStoryFetchEmpty": {
...
break;
}
case "onStoryDismissed": {
...
break;
}
case "onStoryFetchSuccess": {
...
break;
}
case "onStoryLinkClick": {
...
break;
}
}
});
return () => {
playerListener.remove();
}