urbit/pkg/arvo/lib/test/sub.hoon

48 lines
908 B
Plaintext
Raw Normal View History

/+ default-agent, verb, dbug
::
=| state=~
%- agent:dbug
%+ verb &
^- agent:gall
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
::
++ on-poke
|= [=mark =vase]
2022-08-19 14:36:23 +03:00
=+ !<(=ship vase)
?+ mark !!
2022-08-19 14:36:23 +03:00
%leave [[%pass /sub %agent [ship %pub] %leave ~]~ this]
%watch [[%pass /sub %agent [ship %pub] %watch /foo]~ this]
==
::
++ on-watch
|= =path
(on-watch:def +<)
::
++ on-agent
|= [=wire =sign:agent:gall]
?. =(/sub wire)
~| wire+wire !!
~& sub+-.sign
?+ -.sign !!
%kick [[%pass /sub %agent [our.bowl %pub] %watch /foo]~ this]
%fact `this
%watch-ack `this
==
::
++ on-fail
|= [=term =tang]
(mean ':sub +on-fail' term tang)
::
++ on-leave
|= =path
`this
::
2022-08-19 14:36:23 +03:00
++ on-init `this
++ on-save !>(state)
++ on-load |=(old=vase `this(state !<(_state old)))
++ on-arvo on-arvo:def
++ on-peek on-peek:def
--