Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 state

Back to all declarations

realmPath

untyped string

realmPath is this realm's own path, the one its gnomod.toml module line declares. It is written out rather than read from unsafe.CurrentRealm(), which reports the CALLER in every read this realm exports and would therefore build every link against whichever realm embedded the block.

Value

"gno.land/r/moul/reactions/v0"

board

*v0.Board

board holds every page's tally. A redeploy would wipe it, which is why this realm is not private (see gnomod.toml): the state here belongs to everyone who reacted, and the only honest way to change this realm is a v1 beside it.

Open
OID
0b8280…0a70:4
board details

Inspect pointer

React

func(page string, key string)

React records the caller's reaction to page. page is a package path, the full one: "gno.land/r/moul/home". It does not have to be a realm that embeds the block, and nothing checks that it exists. A page is just a name, which is what lets a realm key the block on something finer than itself. key is one of the palette names, not a glyph: "up", "heart", "fire", "party", "rocket", "eyes". Render("") lists them with their emoji. One reaction per address per page. Reacting again with a different key moves it; reacting with the same key changes nothing but the "last reaction" line.

Open
OID
0b8280…0a70:8
React details

Inspect func

Unreact

func(page string)

Unreact removes the caller's reaction from page. It aborts when there is none, rather than succeeding silently, so a misspelled page key is visible instead of looking like a no-op.

Open
OID
0b8280…0a70:10
Unreact details

Inspect func

RenderBlock

func() string

RenderBlock returns the block for the realm CALLING it, which is the form a host realm embeds. It has no cur realm parameter on purpose. A plain read is borrowed: gno opens no realm frame for it, so unsafe.CurrentRealm() reports the caller's path and the block keys itself with no argument. Adding a cur realm here would silently reverse that and key every embed to this realm instead. Calling it from inside this realm therefore keys on this realm, which is never what a caller wants; the views below use the unexported blockFor.

Open
OID
0b8280…0a70:11
RenderBlock details

Inspect func

RenderBlockFor

func(page string) string

RenderBlockFor is [RenderBlock](#RenderBlock) for a named page. Use it from a crossing function, where there is no caller to read off the stack, or when one realm renders several pages.

Open
OID
0b8280…0a70:12
RenderBlockFor details

Inspect func

blockFor

func(page string) string

blockFor is the shared body, so no exported read of this realm calls another and picks up the wrong path.

Open
OID
0b8280…0a70:13
blockFor details

Inspect func

Count

func(page string) int

Count reports how many addresses have a reaction on page.

Open
OID
0b8280…0a70:14
Count details

Inspect func

CountOf

func(page string, key string) int

CountOf reports how many addresses hold one particular reaction on page.

Open
OID
0b8280…0a70:15
CountOf details

Inspect func

ReactionOf

func(page string, who .uverse.address) string

ReactionOf returns who's current reaction key on page, or "" when they have none. A host realm can use it to say "you reacted" without reading the tree.

Open
OID
0b8280…0a70:16
ReactionOf details

Inspect func

Last

func(page string) (key string, who .uverse.address, height int64)
Open
OID
0b8280…0a70:17
Last details

Inspect func

Pages

func() int

Pages reports how many pages have ever been reacted to.

Open
OID
0b8280…0a70:18
Pages details

Inspect func

maxListed

untyped bigint

maxListed caps the board index. The number of pages is unbounded (anyone can react to any key), and a Render that grows with it would eventually be too expensive to serve. The cap is on the INDEX only: every page keeps its own view at /r/moul/reactions/v0:\<page>, whether or not it is listed here.

Value

(25 <untyped> bigint)

Render

func(path string) string

Render serves two views: "" the getting-started page: how to embed the block, plus the board "<page>" one page's tally, where <page> is a package path The page view's path is the key itself, so the link under any embedded block is just this realm's path, a colon, and the page. That is why a page key may contain a colon of its own: "gno.land/r/you/blog:hello" reads back whole.

Open
OID
0b8280…0a70:19
Render details

Inspect func

selfURL

func() string

selfURL is this realm's own gnoweb path, derived from realmPath the same way every link in the block is, so there is one rule and not two. A function and not a package-level var: a package-level var in a realm is realm STATE, persisted and re-read on every call, which is a strange thing for a string the compiler could have folded.

Open
OID
0b8280…0a70:21
selfURL details

Inspect func

renderBoard

func() string

renderBoard lists pages in key order, not by activity. Key order is the order the tree already walks, so the listing is stable between identical calls; ranking would need a second index maintained on every write, which is a lot of machinery for a table nobody navigates by.

Open
OID
0b8280…0a70:23
renderBoard details

Inspect func

renderPage

func(page string) string
Open
OID
0b8280…0a70:24
renderPage details

Inspect func
realmPath : untyped string ="gno.land/r/moul/reactions/v0"
board : *v0.Board Inspect
React : func(page string, key string) Inspect
Unreact : func(page string) Inspect
RenderBlock : func() string Inspect
RenderBlockFor : func(page string) string Inspect
blockFor : func(page string) string Inspect
Count : func(page string) int Inspect
CountOf : func(page string, key string) int Inspect
ReactionOf : func(page string, who .uverse.address) string Inspect
Last : func(page string) (key string, who .uverse.address, height int64) Inspect
Pages : func() int Inspect
maxListed : untyped bigint =(25 <untyped> bigint)
Render : func(path string) string Inspect
selfURL : func() string Inspect
renderHome : func() string Inspect
renderBoard : func() string Inspect
renderPage : func(page string) string Inspect