Count a vote
The JavaScript SDK includes a complete poll example. In a Node project that has @anuna/cbcl, run this command.
node node_modules/@anuna/cbcl/examples/lunch-vote.mjs
Verified lunch-vote
Soup rejected: outside the proposed options
Tally: {"Sushi":1}
On this page
Follow the accepted vote
Alice opens a thread with Sushi and Pizza as the options. Bob supplies a choice and a clock. The runtime binds his intent to the thread and returns canonical act text. The example uses a test identity for Bob. It checks admission before it adds the vote to the history. The runtime calculates the tally from the accepted records.
Change the rule
Copy the shipped dialect into your project:
cp node_modules/@anuna/cbcl/dist/lunch-vote.cbcl poll.cbcl
node node_modules/@anuna/cbcl/examples/lunch-vote.mjs poll.cbcl
Find (domain vote :choice options). The binder checks the choice against the options in the opener. It refuses the intent for Soup.
Change (max-list 24) to (max-list 1). Run the example again. The two-option opener now exceeds the list limit.
For the responsibilities of a networked host, see How a thread becomes state.