Comments (2)
I think for sure you would want to set latest: true so that new requests will cancel the old ones.
You might need to also set a cancelType to the action you use to trigger logout so that it will trigger a cancellation here too.
Also you might need to use the cancelled$ to unsubscribe on cancellation/latest
Code might looks something like:
export const fetchMarkersLogic = createLogic({
type: MARKERS_FETCH_REQUEST,
latest: true, // take latest only
cancelType: MARKERS_LOGOUT, // whatever your logout action is
process({ firebase, action, cancelled$ }, dispatch) {
const { currentUser } = firebase.auth();
const onData = snapshot => {
const markers = _toArray(snapshot.val());
dispatch(
{ type: MARKERS_FETCH_SUCCESS, payload: markers },
{ allowMore: true } // Allow multiple dispatch
);
};
firebase.database().ref(`/markers/${currentUser.uid}`)
.on('value', onData);
cancelled$.subscribe(() =>
firebase.database().ref(/markers/${currentUser.uid}`)
.off('value', onData); // unsusbscribes from firebase on cancellation/latest
)
}
});
from redux-logic.
I'm going to close this issue, we can reopen if need more discussion.
from redux-logic.
Related Issues (20)
- hook for optimistic ui updates
- failType not triggered for rejected promise HOT 3
- Error in StandardAction generic type definition ? HOT 7
- Type error when specifying payload type HOT 2
- Why is CreateLogic.Config.Transform.Hook uses optional argument for reject? HOT 2
- How to delay a dispatch HOT 2
- done cb in finally does not trigger dispatch HOT 2
- Can not make 'latest' property work HOT 2
- processReturn plus processMultiple
- Feature request: `logicMiddleWare.removeLogic(logics)` HOT 2
- can't test Timers and/or cancelType HOT 1
- Is this repo archived, can't see any active development HOT 2
- Type Error while trying to dispatch an Observable
- Improve bundle size by dropping RxJS and improving build process?
- example of post using ajax HOT 4
- `NODE_ENV` is always '' (empty string) in browser. HOT 1
- createLogic type can be string array
- Websockets redux-logic and SSR
- redux-logic v4.0.0 is not in npmjs.com HOT 1
- action (with type) in `catchError` returned observable is not dispatched HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux-logic.