Solved dependency problems when using ViteJs (#269).
It is now possible to subscribe to onSubscriptionChange
on all dispatchers; this allows you to monitor a change in subscriptions. Both onSubscriptionChange
and asEvent
are (now) lazy loading.
Methods that will trigger a change: subscribe
, sub
, unsubcribe
, unsub
, one
and sometimes dispatch
(after a one
trigger is dispatched and that trigger is removed).
Better support for code splitting. All objects now recide in their own class, which makes splitting and tree shaking easier and should produce smaller packages.
New features:
- All
dispatch
methods will now return an IPropagationStatus with an indication if the event was stopped (propagationStopped
). Note: does not work fordispatchAsync
, because this dispatch is not handled synchronously. - We have support for
Promise
handlers, please check PromiseEventDispatcher, PromiseSimpleEventDispatcher and PromiseSignalDispatcher. - A new base class that will give classes generic events: HandlingBase. This base class is now used by all the
...HandlingBase
-classes.
We now have the following packages:
Package | Description |
---|---|
ste-core |
Package that contains all the building blocks for the creation of events. The dispatcher implementation is its main hero. |
ste-events or ste-promise-events |
Events that are modeled after .Net with a sender and argument . If you use typescript, you can leverage the support for generics and get strongly typed code. |
ste-simple-events or ste-promise-simple-events |
A simpler version of the ste-event -event. No sender, just an argument. |
ste-signals or ste-promise-signals |
A signal is even simpler, it is just a callback for when you need to be alerted without any scope. |
strongly-typed-events |
This package includes everything. |
ste-browser |
Helps to host events in the browser. |
Added browser support for the individual flavors of events:
<script src="https://cdn.jsdelivr.net/npm/ste-browser@latest/dist/ste-events.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ste-browser@latest/dist/ste-events.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ste-browser@latest/dist/ste-simple-events.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ste-browser@latest/dist/ste-simple-events.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ste-browser@latest/dist/ste-signals.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ste-browser@latest/dist/ste-signals.min.js"></script>
@DustinWoods added support for non uniform event lists.
Added support for subscription .count
from the dispatcher.
Added support for UMD for the ste-browser package.
We transformed the single package to 5 packages:
Package | Description |
---|---|
ste-core |
Package that contains all the building blocks for the creation of events. The dispatcher implementation is its main hero. |
ste-events |
Events that are modeled after .Net with a sender and argument . If you use typescript, you can leverage the support for generics and get strongly typed code. |
ste-simple-events |
A simpler version of the ste-event -event. No sender, just an argument. |
ste-signals |
A signal is even simpler, it is just a callback for when you need to be alerted without any scope. |
strongly-typed-events |
This package includes everything. |
Added ev.stopPropagation
and ev.unsub()
to aid in event management. Each event type has an extra parameter that can be used to manage the event:
//log the name of the clock and the tick argument to the console - this is an event
clock.onClockTick.subscribe((c, n, ev) =>
console.log(`${c.name} ticked ${n} times.`)
//stop further event propagation:
ev.stopPropagation();
//unsubscribes the event handler that caused the event:
ev.unsub();
);
Removed the static. Internal restructuring of the package. Removed default exports, all exports are now named. This is a breaking change.
An unsubscribe function is now returned when registering a subscription: let unsub = x.sub(x => {}); unsub();
.
Added default exports. Removed emulation through window.
Restructured includes for 'normal' web applications. Using import
/ export
mechanisme. Emulating exports
and require
nodes through the window
object for web.
Introduced the one
method on events to subscribe only once. Added sub
and unsub
methods as shorthands for subscribe
and unsubscribe
. Added a has
method to check if a handler has been registered.
Now supports Node.js through npm package: npm i strongly-typed-events
. Rewrote and split tests.
0.4.2: Introduced the clear
method on events to clear all subscriptions.
Introduced signal – events that contain no data and just fire. The unit tests now support modules. The following objects and features are present in this version:
ISignal
– Event handler function for a signal.SignalDispatcher
– Dispatcher implementation for signals. Can be used to subscribe, unsubscribe or dispatch events. Use the ToEvent() method to expose the event.SignalList
– Storage class for multiple signals that are accessible by name. Dispatchers are automatically created.SignalHandlingBase
– Extends objects with signal handling capabilities.
Introduced simple events – events that only use an arguments object. I've added many base classes and interfaces to make sure the base for both type of events are the same. The following objects and features are present in this version:
ISimpleEvent<TArgs>
– Event handler function with a generic argument.SimpleEventDispatcher<TArgs>
– Dispatcher implementation for simple events. Can be used to subscribe, unsubscribe or dispatch events. Use the ToEvent() method to expose the eventSimpleEventList<TArgs>
– Storage class for multiple events that are accessible by name. Events dispatchers are automatically created.SimpleEventHandlingBase<TArgs>
– Extends objects with simple event handling capabilities.- Added an
asEvent
method to the dispatchers that will expose only the subsribe / unsubscribe methods. This will prevent thedispatch
method from being exposed through the events. - Added an
dispatchAsync
method to the dispatchers that will execute all subsriptions asynchronously. Check this for more information.
Introducing the events - use a generic sender and a generic argument to dispatch events through your projects. The following objects and features are present in this version:
IEvent<TSender, TArgs>
– Event handler function with a generic sender and a generic argument.EventDispatcher<TSender, TArgs>
– Dispatcher implementation for events. Can be used to subscribe, unsubscribe or dispatch events. Use the ToEvent() method to expose the event.EventList<TSender, TArgs>
– Storage class for multiple events that are accessible by name. Events dispatchers are automatically created.EventHandlingBase<TSender, TArgs>
– Extends objects with event handling capabilities.