11"use strict" ;
22
3- import { ProcessSystem , GenServer } from "../src/processes" ;
3+ import { ProcessSystem , GenServer , Application } from "../src/processes" ;
44self . system = self . system || new ProcessSystem ( ) ;
55
6+ let myApp = {
7+ start : function ( type , args ) {
8+ let pid = self . system . spawn ( function * ( ) {
9+ var pid1 = self . system . spawn_link ( function * ( ) {
10+ while ( true ) {
611
7- var pid1 = system . spawn ( function * ( ) {
8- while ( true ) {
12+ yield self . system . receive ( function ( value ) {
13+ return console . log ( value ) ;
14+ } ) ;
915
10- yield system . receive ( function ( value ) {
11- return console . log ( value ) ;
16+ self . system . send ( pid2 , "message from 1" ) ;
17+ }
1218 } ) ;
1319
14- system . send ( pid2 , "message from 1" ) ;
15- }
16- } ) ;
20+ self . system . register ( "Sally" , pid1 ) ;
1721
18- system . register ( "Sally" , pid1 ) ;
1922
23+ var pid2 = self . system . spawn_link ( function * ( ) {
24+ while ( true ) {
25+
26+ self . system . send ( "Sally" , "message from 2" ) ;
2027
21- var pid2 = system . spawn ( function * ( ) {
22- while ( true ) {
23-
24- system . send ( "Sally" , "message from 2" ) ;
28+ yield self . system . receive ( function ( value ) {
29+ return console . log ( value ) ;
30+ } ) ;
31+ }
32+ } ) ;
2533
26- yield system . receive ( function ( value ) {
27- return console . log ( value ) ;
34+ yield self . system . receive ( function ( value ) {
35+ return Symbol . for ( "no_match" ) ;
36+ } ) ;
2837 } ) ;
38+
39+ return [ Symbol . for ( "ok" ) , pid ] ;
2940 }
30- } ) ;
41+ } ;
42+
43+ let pid = Application . start ( myApp ) ;
0 commit comments