Course · Lesson 11 of 20

Publish messages and ask before acting

Connect a named event to subscribers and test confirmation, cancellation and repeated actions.

Reading · Practice2 sectionsPrerequisites: Style the page you own
Course contents

A message expresses an event

A Data binding observes a value. A topic message announces an event, including repeated events with the same payload. gramlot.publish delivers a topic and arguments; a declared subscribe_saved controller can listen for the saved topic.

In Publish and subscribe, compare the publisher with the receiving controller. Subscribers belong to a page. Parent/child forwarding is a separate, explicit route; it is not broadcasting to arbitrary browser windows.

Put a confirmation on the action

Use the Actions, confirmations and references example to inspect ask and _ask. A button action uses ask; a provider such as a controller uses _ask. Confirm executes the action with the dialog values. Cancel or Escape does not execute it.

An authored reference addresses a live Source node. If that node disappears while a dialog waits, the later action cannot treat it as a valid target. Test cancellation and removal as well as the successful path.

Your turn

Try it yourself

  1. In Publish and subscribe, publish the same event twice and observe both deliveries.
  2. In Actions, confirmations and references, open a confirmation and cancel it. Record whether the action ran.
  3. Repeat, confirm once and compare the result with cancellation.

Check your understanding

Why is publishing saved twice different from storing the same boolean twice?

Show the answer and expected result

A topic represents a delivery, and equal payloads are delivered again. A value describes state. Choose the mechanism that expresses the intended action. Confirmation controls whether that action runs; it does not itself persist a record.

Working examples and reference