A library for creating event-based applications
Overview
The library consists of 2 traits:
- [
Receive
][receive::Receive
]: a generic interface for sending events - [
View
][view::View
]: a generic interface for viewing events
Viewer return;
- [
DeleteView
][view::DeleteView
]: flag to delete the viewer
Receiver return, [ReceiverResult
][receive::ReceiverResult
]:
- [
Continue
][receive::ReceiverResult::Continue
]: continue processing the output as normal (like [Some
]) - [
Stop
][receive::ReceiverResult::Stop
]: stop processing the output (like [None
]`) - [
Delete
][receive::ReceiverResult::Delete
]: gives back the event with the flag that the receiver should be deleted, this is specifically for communication with routers so that intercepts can be cleanly destructed while letting the event pass through
The different ways to store receivers and viewers are:
- [
RcLinker
][rc_linker::RcLinker
] and [ArcLinker
][arc_linker::ArcLinker
]: a smart pointer that will mark any instances of [RcLinked
][rc_linker::rc_linked::RcLinked
] or [ArcLinked
][arc_linker::arc_linked::ArcLinked
] ready for deletion when dropped, cleaning up any dangling references. - [
Exposed
][exposed::Exposed
]: a container for a receiver that allows multiple [View
][view::View
]ers to be prepended - [
Router
][router::Router
]: a container for a receiver that allows another router to intercept the event at the beginning, by repeating the intercept function it will be delegated to lower routers, allowing a level of abstraction where an intercept does what is expected without breaking the rest of the router.
Aproach
The receivers function as a sort of lazy garbage collector.
When receivers flags that they wish to be deleted ([Delete
][receive::ReceiverResult::Delete
]), it should
be expected that everything occuring before the introduction of the flag was ran, including viewers and intercepters.
This mean if [Delete
][receive::ReceiverResult::Delete
] is received, it is expected that all prior systems
have ran and responsibilty falls upon the receiver to continue the event propgation with minimal interuptions.
The exception to this is [Stop
][receive::ReceiverResult::Stop
], which marks that a decision has been made to exit
the event propgation.
This means if [Stop
][receive::ReceiverResult::Stop
] is received, it is expected that not all prior systems
have ran and responsibilty falls upon the receiver to exit the event propgation with minimal impact.