Skip to main content

๐Ÿชข Bindings

LogicBlocks provides a binding system that allows objects to listen to a particular logic block. Bindings allow you to observe inputs, outputs, errors, and state changes declaratively.

๐Ÿ“ฅ Observing Inputsโ€‹

using var binding = logic.Bind();

binding.Watch((in MyLogicBlock.Input.SomeInput input) => {
// Watch for a particular input.
});

๐Ÿ“ค Observing Outputsโ€‹

using var binding = logic.Bind();

binding.Handle((in MyLogicBlock.Output.SomeOutput output) => {
// Handle a particular output.
});

๐Ÿ”„ Observing State Changesโ€‹

using var binding = logic.Bind();

binding.When<MyLogicBlock.State.SomeState>(state => {
// Respond to a state change. This is only called when changing from a state
// that is not the type specified.
});

๐Ÿšจ Observing Errorsโ€‹

using var binding = logic.Bind();

binding.Catch<System.Exception>(e => {
// Catch an error.
});