def relation_prepared

bendvy-ecs-core@0.1.0.4 · ordinary_reader_stream_parameter.bend:595

import bendvy-ecs-core@0.1.0.4/ordinary_reader_stream_parameter.bend as OrdinaryReaderStreamParameter
import Base
import bendvy-ecs-core@0.1.0.4/event_runtime.bend as Ev
import bendvy-ecs-core@0.1.0.4/event_family_routing.bend as Route
import bendvy-ecs-core@0.1.0.4/event_notice_runtime.bend as Mixed
import bendvy-ecs-core@0.1.0.4/relation_commands.bend as Notice
import bendvy-ecs-core@0.1.0.4/relation_failure_runtime.bend as K
import bendvy-ecs-core@0.1.0.4/internal/relation_failures/readings.bend as KRead

595def relation_prepared(~S:Data,~C:Type,~R:Type,~P:Data,~F:Type,~H:Type,
596  context:Route.Runtime<S,C,R,Notice.Notice<S,P>,Mixed.State<S,P,F,H>>,
597  owner:RelationOwner<S,P>) -> Route.Runtime<S,C,R,Notice.Notice<S,P>,Mixed.State<S,P,F,H>> & (RelationOwner<S,P> & (RelationView<S,P> & RelationDelta)):
598  match context owner:
599    case Route.Runtime{world,Mixed.State{typed,Mixed.Failures{+domains,+positions,+tick,frameStart,boundary,capacity,nextReader}},routeTick} RelationOwner{facts,+id,+keys}:
600      match id:
601        case None{}:
602          +readThrough=tick
603          (Route.Runtime{world,Mixed.State{typed,Mixed.Failures{domains,positions,tick,frameStart,boundary,capacity,nextReader}},routeTick},
604            (RelationOwner{facts,id,keys},(RelationView{[]},RelationDelta{id,readThrough})))
605        case Some{+readerId}:
606          +position=K.position_or(Ev.lookup(positions,readerId),readerId,tick)
607          +readings=KRead.all(~S,~Notice.Notice<S,P>,keys,domains,position)
608          +readThrough=tick
609          # Match standalone failed reads: activation retains unread input,
610          # while only the successful commit advances its cursor.
611          (Route.Runtime{world,Mixed.State{typed,Mixed.Failures{
612            KRead.activate(~S,~Notice.Notice<S,P>,keys,domains,readerId),
613            Ev.activate(positions,readerId,tick),tick,frameStart,boundary,capacity,nextReader}},routeTick},
614            (RelationOwner{facts,id,keys},(RelationView{readings},RelationDelta{id,readThrough})))

Uses (16)

Used by (1)