v1.1.2 - Global FlushEngine
This release focuses on FlushEngine (previously SpokeEngine), and the choice to have a global engine for all behaviours, or each behaviour having its own. In past releases, every SpokeBehaviour had its own FlushEngine. This lets an engine flush, and during its flush trigger another to engine flush, resulting in a nested flush. This is powerful, but dangerous if not careful. The default now is a single global FlushEngine at the root of all SpokeBehaviour engines, so only one can flush at a time.
Nested flushing is still possible by creating seperate trees with SpokeRoot.Create(new FlushEngine(...)). But this is now an advanced opt-in feature, not the default.
Another important change is s.Export and s.Import. Example:
s.Effect(s => {
s.Export(new SomeResource());
s.Effect(s => {
var resource = s.Import<SomeResource>();
});
});Exported objects are visible on the lexical scope. All descendants and later siblings can import it.
Changelist:
SpokeEnginerenamed toFlushEngine, and the base classExecutionEnginetakes the nameSpokeEngineFlushEngine.Batch()is a static method that holds all engines from flushing. It replaces the per-engine batchingFlushEngine.Globalis one engine that allSpokeBehaviourwill attach to. The implication is only oneSpokeBehaviourhas flush at onceFlushEngine.AddFlushRegionlets you conveniently attach a nestedFlushEngineunder another. This is whatSpokeBehaviouris usings.Exportands.ImportreplacesTryGetLexicalandTryGetContext- Correctly handle Epochs that dispose their own root, or drop themselves from a dock mid-execution
- Correctly order all
Call,OnCleanupandUseresources in a single array. Now they are truly disposed in reverse-declaration order