Closed MaxGraey closed 6 years ago
Back in 2016 (which is almost 2 years ago) when I started React Coroutine, it was a solution for my project that made code way flexible comparing to what it was being written with React Transmit. The code is still in production and I continue using React Coroutine for an extended set of cases and not just for pet projects. This means, if I encounter any issue, I need to immediately fix it.
Comparing to async-reactor
, I see a set of implementation differences:
for..await..of
and yield/await
work without limitations in the same way as defined by the language spec.Such differences allows to do much more with your components, keeping the same level of simplicity and expectations. Here are some of the cases I use frequently:
export default Coroutine.create(DataVizCoroutine);
async function* DataVizCoroutine({ bucketId, dataFilter }) {
let filterSetup = await ConfigAPI.retrieve({ dataFilter });
// Assuming `ConfigAPI` has almost immediate result, rendering partial state
yield <DataViz filters={filterSetup} />;
// Awaiting for heavy data to arrive at some point
let dataBuckets = await DataStorageAPI.retrieve({ bucketId });
// Rendering the same component but with complete data. The UI transition
// happens without blinking.
return <DataViz filters={filterSetup} data={dataBuckets} />;
}
export default Coroutine.create(ResourceMonitorCoroutine);
async function* ResourceMonitorCoroutine({ resourceId }) {
yield <p>Awaiting for resource usage stats...</p>;
for await (let stats of ResourcesAPI.subscribeTo(resourceId)) {
yield <ResourceUsage stats={stats} />;
}
}
I hope this answers your question. I may need to update some parts of docs to reflect the flexibility and specific use cases besides just fetching data and doing code splitting.
Thanks
Hi! Could you explain please what's benefits comparable to async-reactor your project have? It seems this two projects very quite similar except Async Reactor by xtuc is more mature?