One of my top reasons for using redux-saga is how testable it makes asynchronous function calls. My dilemma is that when I am programming with stateful objects that wouldn't belong inside my redux store it becomes pretty awkward programming with sagas. Is there a best practice for working with non-pure data objects and redux-saga?
Say I have callback functions I register with an API, firebase in this case, and I need to book keep these callback functions so I can unregister them later. I can't store these callback functions in redux, so does it still make sense to write this as a saga?
Seems a bit weird in one piece of code to be able to use things like put, select and in other bits of code I have to use store.dispatch.
Example:
const childAddedTrigger = (dataSnapshot: firebase.database.DataSnapshot) => {
const message = Object.assign({}, dataSnapshot.val(), {
key: dataSnapshot.key,
});
service.store.dispatch(Actions.channelMessageAdded(channelId, message));
}
service.firebase.database().ref(`channels/${channelId}/messages`)
.limitToLast(20)
.on('child_added', childAddedTrigger);
this.channelSubscriptions[channelId] = childAddedTrigger;