execution_lifetime_scope_command.bend

bendvy-ecs-core@0.1.0.3 · 18 lines · 5 definitions

1import Base
2import bendvy-ecs-core@0.1.0.3/world.bend as W
3import bendvy-ecs-core@0.1.0.3/lifetime_scope.bend as Scope
4import bendvy-ecs-core@0.1.0.3/execution_composer_layout.bend as Layout
5
6type Operation<-S:Data> is Data:
7  Assign{scope:Scope.Scope<S>,handle:W.Handle<S>}
8  Cleanup{scope:Scope.Scope<S>}
9type Commands<-Q:Type,-S:Data> is Type:
10  Commands{assign:Q -> Scope.Scope<S> -> W.Handle<S> -> Q,cleanup:Q -> Scope.Scope<S> -> Q}
11def provide(~S:Data,~Q:Type,~route:Layout.Route,~enqueue:Q -> Layout.Route -> Operation<S> -> Q) -> Commands<Q,S>:
12  Commands{queue => scope => handle => enqueue(queue,route,Assign{scope,handle}),queue => scope => enqueue(queue,route,Cleanup{scope})}
13def assign_field(~S:Data,~Q:Type,commands:Commands<Q,S>) -> Q -> Scope.Scope<S> -> W.Handle<S> -> Q:
14  match commands:
15    case Commands{assign,_}:assign
16def cleanup_field(~S:Data,~Q:Type,commands:Commands<Q,S>) -> Q -> Scope.Scope<S> -> Q:
17  match commands:
18    case Commands{_,cleanup}:cleanup