Closed shinkathe closed 6 years ago
This sounds like something that might kill garbage collection.
Any reason you couldn't monkeypatch flyd for this?
import flyd from 'flyd';
const _stream = flyd.stream;
const streams = [];
flyd.stream = (...args)=> {
const s = _stream(...args);
streams.push(s);
return s;
}
const expandStream = s => [s, s.listeners && s.listeners.map(expandStream), s.deps && s.deps.map(expandStream)];
export const getAllStreams = ()=> {
return R.uniq(R.flatten(streams.map(expandStream))).filter(Boolean);
}
This works, thanks.
That is a very nice trick @nordfjord. Thank you for asking a very good question @shinpou. I've never thought of doing profiling like that myself but I can definitely see how it could be useful.
Use case: I would like to add a listener to all streams that have been created all around the application to be able to create aggregate reports of streams that are updated the most vs least and be able to find spots where updates are being unnecessarily made or find optimization points that are the highest impact.