mirror of
https://github.com/urbit/shrub.git
synced 2024-12-15 21:03:10 +03:00
50 lines
1.3 KiB
Plaintext
50 lines
1.3 KiB
Plaintext
/+ tapp, stdio
|
|
=>
|
|
|%
|
|
+$ subscription-state
|
|
$: target=[her=ship app=term]
|
|
=path
|
|
==
|
|
+$ state
|
|
$: subscription=(unit subscription-state)
|
|
==
|
|
+$ in-poke-data [%noun =cord]
|
|
+$ out-poke-data [%noun =cord]
|
|
+$ out-peer-data ~
|
|
+$ in-peer-data
|
|
$% [%comments comments=(list tape)]
|
|
==
|
|
++ tapp (^tapp state in-poke-data out-poke-data in-peer-data out-peer-data)
|
|
++ stdio (^stdio out-poke-data out-peer-data)
|
|
--
|
|
=, trad=trad:tapp
|
|
=, tapp-trad=tapp-trad:tapp
|
|
=, stdio
|
|
%- create-tapp-poke-diff:tapp
|
|
^- tapp-core-poke-diff:tapp
|
|
|_ [=bowl:gall state]
|
|
++ handle-poke
|
|
|= =in-poke-data
|
|
=/ m tapp-trad
|
|
^- form:m
|
|
?: =(cord.in-poke-data 'pull')
|
|
?~ subscription
|
|
(trad-fail %no-subscription ~)
|
|
;< ~ bind:m (pull-app [target path]:u.subscription)
|
|
(pure:m ~)
|
|
=/ target [our.bowl %example-tapp-fetch]
|
|
;< ~ bind:m (poke-app target %noun 'print')
|
|
;< ~ bind:m (peer-app target /comments)
|
|
=. subscription `[target /comments]
|
|
;< ~ bind:m (wait (add now.bowl ~s3))
|
|
(pure:m subscription)
|
|
::
|
|
++ handle-diff
|
|
|= [[her=ship app=term] =path data=in-peer-data]
|
|
=/ m tapp-trad
|
|
^- form:m
|
|
?> ?=(%comments -.data)
|
|
~& subscriber-got-data=(lent comments.data)
|
|
(pure:m subscription)
|
|
--
|