Replies: 2 comments
-
Using something like saga-query could help import { createPipe } from 'saga-query';
// saga middleware system
export const timer = createPipe();
timer.use(function* (ctx, next) {
const t0 = performance.now();
yield next();
const t1 = performance.now();
console.log(`Call to ${ctx.name} took ${t1 - t0} milliseconds.`);
});
timer.use(timer.routes());
// your saga function
function* randomSagaFunction(action) {
...does stuff and has multiple effects
}
const randomSaga = timer.create('random-saga', function* (ctx) {
yield call(randomSagaFunction, ctx.action);
})
// use it in another saga
function* someOtherSaga() {
yield call(randomSaga.run, randomSaga())
}
// call it directly
store.dispatch(randomSaga()); It seems a little round-about but once you have |
Beta Was this translation helpful? Give feedback.
-
I was inspired by this post to make import { performanceMonitor, createPipe, wrap, PerfCtx, delay } from 'saga-query';
const thunks = createPipe<PerfCtx>();
thunks.use(function* (ctx, next) {
yield next();
console.log(`calling ${ctx.name} took ${ctx.performance} ms`);
});
thunks.use(performanceMonitor);
thunks.use(thunks.routes());
// your saga function
function* randomSagaFunction(action) {
...does stuff and has multiple effects
}
const slow = thunks.create('something-slow', wrap(randomSagaFunction));
store.dispatch(slow());
// calling something-slow took 10000 ms
happy to read any thoughts! |
Beta Was this translation helpful? Give feedback.
-
Hello! I am wondering if there some middleware someone is aware of that would allow me to track an individual sagas from start to finish? I have been experimenting with sagamonitor middleware but that logs every single effect and you can have multiple effects inside a saga. Example:
Then in my application saga I fork my sagas like
I would ultimately like to track how long randomSagaFunction takes without adding instrumentation to every single saga function in my app. Wondering if there is a middleware that would accomplish this that I am missing....
Beta Was this translation helpful? Give feedback.
All reactions