urbit/pkg/arvo/app/soto.hoon

75 lines
1.4 KiB
Plaintext
Raw Normal View History

2019-11-22 03:51:52 +03:00
::
:: soto [landscape]: A Dojo relay for Urbit's Landscape interface
::
2019-11-22 03:51:52 +03:00
:: Relays sole-effects to subscribers and forwards sole-action pokes
::
/- sole
/+ *soto, default-agent
2019-11-22 03:51:52 +03:00
|%
+$ card card:agent:gall
::
2020-06-18 14:47:44 +03:00
+$ versioned-state
$@ state-null
state-zero
::
+$ state-null ~
::
+$ state-zero [%0 ~]
2019-11-22 03:51:52 +03:00
--
=| state-zero
=* state -
^- agent:gall
|_ bol=bowl:gall
+* this .
soto-core +>
sc ~(. soto-core bol)
def ~(. (default-agent this %|) bol)
::
2020-06-18 14:47:44 +03:00
++ on-init
:_ this
:_ ~
:* %pass /srv %agent [our.bol %file-server]
%poke %file-server-action
!>([%serve-dir /'~dojo' /app/landscape %.n %.y])
2020-06-18 14:47:44 +03:00
==
2019-11-22 03:51:52 +03:00
++ on-save !>(state)
::
++ on-load
2020-06-18 14:47:44 +03:00
|= old-vase=vase
=/ old
!<(versioned-state old-vase)
?^ old
[~ this(state old)]
:_ this(state [%0 ~])
:~ [%pass /bind/soto %arvo %e %disconnect [~ /'~dojo']]
:* %pass /srv %agent [our.bol %file-server]
%poke %file-server-action
!>([%serve-dir /'~dojo' /app/landscape %.n %.y])
==
==
2019-11-22 03:51:52 +03:00
::
++ on-poke on-poke:def
2019-11-22 03:51:52 +03:00
++ on-watch
|= pax=path
^- (quip card _this)
?+ pax (on-watch:def pax)
2019-11-22 03:51:52 +03:00
[%sototile ~]
:_ this
[%give %fact ~ %json !>(~)]~
==
::
++ on-agent on-agent:def
::
++ on-arvo
|= [wir=wire sin=sign-arvo]
^- (quip card _this)
?: ?=(%bound +<.sin)
[~ this]
(on-arvo:def wir sin)
::
++ on-fail on-fail:def
++ on-leave on-leave:def
++ on-peek on-peek:def
::
--