Peer working
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Machine, State, On, SideEffect, Goto, Interpreter, Interpreter_T, send, Event_T, Context, SideEffectFunction_T, Peer, PeerCreationFunction_T, ContextMutationFunction_T } from '../index';
|
||||
|
||||
const wait = (ms:number)=>new Promise((resolve)=>{ setTimeout(()=>{ resolve(1); }, ms); });
|
||||
const makeRequest : SideEffectFunction_T<Cc> = (ctx,e,self)=>{ send(self.peers.server, ['received-request',self]); };
|
||||
const makeRequest : SideEffectFunction_T<Cc> = (ctx,e,self)=>{ send((self.peers.server as Interpreter_T<Cs>), ['received-request',self]); };
|
||||
const sendResponse : SideEffectFunction_T<Cs> = (ctx,e,self)=>{ send(ctx.client, ['received-response',self]); };
|
||||
const startTimer : SideEffectFunction_T<Cs> = async (ctx,e,self)=>{ await wait(1500); console.log(' timer actually finished'); send(self, ['timer-finished',null]); }
|
||||
const log = (namespace:string)=>(ctx, e, self)=>{ console.log(namespace, self.state, e[0]); };
|
||||
|
||||
Reference in New Issue
Block a user