mirror of
https://github.com/urbit/shrub.git
synced 2024-12-21 09:51:36 +03:00
b3901ab42f
git-subtree-dir: pkg/arvo git-subtree-mainline:9c8f40bf6c
git-subtree-split:c20e2a185f
51 lines
1.3 KiB
Plaintext
51 lines
1.3 KiB
Plaintext
/+ tapp, stdio
|
|
=>
|
|
|%
|
|
+$ subscription-state
|
|
$: target=[her=ship app=term]
|
|
=path
|
|
==
|
|
+$ state
|
|
$: subscription=(unit subscription-state)
|
|
==
|
|
+$ peek-data _!!
|
|
+$ in-poke-data [%noun =cord]
|
|
+$ out-poke-data [%noun =cord]
|
|
+$ out-peer-data ~
|
|
+$ in-peer-data
|
|
$% [%comments comments=(list tape)]
|
|
==
|
|
++ tapp (^tapp state peek-data in-poke-data out-poke-data in-peer-data out-peer-data)
|
|
++ stdio (^stdio out-poke-data out-peer-data)
|
|
--
|
|
=, async=async:tapp
|
|
=, tapp-async=tapp-async:tapp
|
|
=, stdio
|
|
%- create-tapp-poke-diff:tapp
|
|
^- tapp-core-poke-diff:tapp
|
|
|_ [=bowl:gall state]
|
|
++ handle-poke
|
|
|= =in-poke-data
|
|
=/ m tapp-async
|
|
^- form:m
|
|
?: =(cord.in-poke-data 'pull')
|
|
?~ subscription
|
|
(async-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-async
|
|
^- form:m
|
|
?> ?=(%comments -.data)
|
|
~& subscriber-got-data=(lent comments.data)
|
|
(pure:m subscription)
|
|
--
|