import { ActionPattern } from "@redux-saga/types" ; import { take } from "redux-saga/effects" ; import { OpcodesForPacket , PacketSet } from "../packet" ; import { OutgoingRegistry } from "../registry/outgoing" ; import { Action , ActionStreamPacket , ActionStreamPayload } from "./packet" ; param registry param opcode The opcode to use, must be registered to a  ActionStreamPacket in the  PacketSet param actions export const outgoingSaga = < TPacketSet extends PacketSet , TOpcode extends keyof OpcodesForPacket < TPacketSet , ActionStreamPacket > > ( registry , opcode , actions ) => function * ( ) { let lastSentIndex = 0 ; while ( true ) { const action = yield take ( actions ) ; const index = ++ lastSentIndex ; const payload = { index , actions : [ action ] } ; registry . send ( opcode , payload ) ; } } ;