This class represents a sequence of transformations that are applied to events feeding into an EventListener EventProcessor-s are immutable, so can be reused by multiple setters.
Example syntax: input(onChange().preventDefault.mapTo(true) --> myBooleanWriteBus)
Note: Params are protected to avoid confusing autocomplete options (e.g. "useCapture")
Value parameters
- processor
-
Processes incoming events before they're passed to the next processor or to the listening EventBus. Returns an Option of the processed value. If None, the value should not passed down the chain.
- shouldUseCapture
-
(false means using bubble mode) See
useCapture
docs here: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Concrete methods
Similar to the Airstream compose
operator.
Similar to the Airstream compose
operator.
Use this when you need to apply stream operators on this element's events, e.g.:
div(onScroll.compose(_.throttle(100)) --> observer)
a(onClick.preventDefault.compose(_.delay(100)) --> observer)
Note: can also use with more compact apply
alias:
div(onScroll(_.throttle(100)) --> observer)
a(onClick.preventDefault(_.delay(100)) --> observer)
Note: This method is not chainable. Put all the operations you need inside the operator
callback.
Attributes
Values that do not pass the test will not propagate down the chain and into the emitter.
Values that do not pass the test will not propagate down the chain and into the emitter.
Attributes
Filter events by event.target
Filter events by event.target
For example, discard clicks on child links with something like:
div( onClick.filterByTarget { case dom.html.Anchor => false case _ => true } --> observer, "A bunch of clickable stuff", a("Some link", href("...")) )
Attributes
Values that pass the test will not propagate down the chain and into the emitter.
Values that pass the test will not propagate down the chain and into the emitter.
Attributes
Similar to the Airstream flatMap
operator.
Similar to the Airstream flatMap
operator.
Use this when you want to create a new stream or signal on every event, e.g.:
button(onClick.preventDefault.flatMap(_ => makeAjaxRequest()) --> observer)
#TODO[IDE] IntelliJ (2022.3.2) shows false errors when using this flatMap implementation, at least with Scala 2, making it annoying. Use flatMapStream or flatMapSignal to get around that. https://youtrack.jetbrains.com/issue/SCL-21836/Kind-context-bound-callback-argument-causes-false-positive-type-mismatch-error
Note: This method is not chainable. Put all the operations you need inside the operator
callback, or use the compose
method instead for more flexibility
Attributes
Similar to flatMap
, but restricted to signals only.
Similar to flatMap
, but restricted to signals only.
Attributes
Similar to flatMap
, but restricted to streams only.
Similar to flatMap
, but restricted to streams only.
Attributes
Equivalent to flatMap(_ => observable)
Equivalent to flatMap(_ => observable)
Note: observable
will be re-evaluated every time the event is fired.
Attributes
Similar to Airstream flatMapWithStatus
operator.
Similar to Airstream flatMapWithStatus
operator.
Use this when you want to flatMapSwitch and get a status indicating whether the input has been processed by the inner stream, e.g.:
button(onClick.flatMapWithStatus(ev => AjaxStream.get(ev, ...)) --> observer
Attributes
Similar to Airstream flatMapWithStatus
operator.
Similar to Airstream flatMapWithStatus
operator.
Use this when you want to flatMapSwitch and get a status indicating whether the input has been processed by the inner stream, e.g.:
button(onClick.flatMapWithStatus(AjaxStream.get(...)) --> observer
Attributes
(originalEvent, accumulatedValue) => newAccumulatedValue
(originalEvent, accumulatedValue) => newAccumulatedValue
Unlike other processors, this one will fire regardless of .filter-s up the chain. Instead, if the event was filtered, project will receive None as accumulatedValue. The output of project should be Some(newValue), or None if you want to filter out this event.
Attributes
Same as map(_ => value)
Same as map(_ => value)
Note: value
will be re-evaluated every time the event is fired
Attributes
Get the value of event.target.checked
Get the value of event.target.checked
Attributes
Get the original event. You might want to call this in a chain, after some other processing.
Get the original event. You might want to call this in a chain, after some other processing.
Attributes
Get the value of event.target.files
Get the value of event.target.files
Attributes
- See also
Like mapTo, but with strict evaluation of the value
Like mapTo, but with strict evaluation of the value
Attributes
Unsafe – Get the value of event.target
, cast to a certain element type
Unsafe – Get the value of event.target
, cast to a certain element type
You should generally avoid this in favor of other helpers like mapToValue
or inContext { thisNode => ... }
.
Attributes
Get the value of event.target.value
Get the value of event.target.value
Attributes
Use a standard non-passive listener. You don't need to call this unless you set passive
previously, and want to revert to non-passive.
Use a standard non-passive listener. You don't need to call this unless you set passive
previously, and want to revert to non-passive.
See passive
docs here: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#passive
Attributes
Evaluate f
if the value was filtered out up the chain. For example:
Evaluate f
if the value was filtered out up the chain. For example:
onClick.filter(isRightClick).orElseEval(_.preventDefault()) --> observer
This observer will fire only on right clicks, and for events that aren't right clicks, ev.preventDefault() will be called instead.
Attributes
Use a passive event listener
Use a passive event listener
Note that unlike preventDefault
config which applies to individual events, passive
is used to install the listener onto the DOM node in the first place.
See passive
docs here: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#passive
Attributes
Prevent default browser action for the given event (e.g. following the link when it is clicked) https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
Prevent default browser action for the given event (e.g. following the link when it is clicked) https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
Note: this is just a standard processor, so it will be fired in whatever order you have applied it. So for example, you can filter events before applying this, preventing default action only for certain events.
Example: input(onKeyUp().filter(ev => ev.keyCode == KeyCode.Tab).preventDefault --> tabKeyUpBus)
Attributes
Write the resulting boolean into event.target.checked
. You can only do this on checkbox or radio button elements.
Write the resulting boolean into event.target.checked
. You can only do this on checkbox or radio button elements.
Warning: if using this, do not use preventDefault. The browser may override the value you set here.
Attributes
Write the resulting string into event.target.value
. You can only do this on elements that have a value property - input, textarea, select
Write the resulting string into event.target.value
. You can only do this on elements that have a value property - input, textarea, select
Attributes
Write a custom boolean into event.target.checked
. You can only do this on checkbox or radio button elements.
Write a custom boolean into event.target.checked
. You can only do this on checkbox or radio button elements.
Warning: if using this, do not use preventDefault. The browser may override the value you set here.
Attributes
Write a custom string into event.target.value
. You can only do this on elements that have a value property - input, textarea, select
Write a custom string into event.target.value
. You can only do this on elements that have a value property - input, textarea, select
Attributes
This method prevents other listeners of the same event from being called. If several listeners are attached to the same element for the same event type, they are called in the order in which they were added. If stopImmediatePropagation() is invoked during one such call, no remaining listeners will be called.
This method prevents other listeners of the same event from being called. If several listeners are attached to the same element for the same event type, they are called in the order in which they were added. If stopImmediatePropagation() is invoked during one such call, no remaining listeners will be called.
MDN https://developer.mozilla.org/en-US/docs/Web/API/Event/stopImmediatePropagation
Note: this is just a standard processor, so it will be fired in whatever order you have applied it. So for example, you can filter events before applying this, propagation will be stopped only for certain events.
Example: div(onClick.filter(isGoodClick).stopImmediatePropagation --> goodClickBus)
Attributes
Propagation here refers to DOM Event bubbling or capture propagation. https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation
Propagation here refers to DOM Event bubbling or capture propagation. https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation
Note: this is just a standard processor, so it will be fired in whatever order you have applied it. So for example, you can filter events before applying this, propagation will be stopped only for certain events.
Example: div(onClick.filter(isGoodClick).stopPropagation --> goodClickBus)
Attributes
Execute a side effecting callback every time the event emits.
Execute a side effecting callback every time the event emits.
Note: Do not provide a callback that returns a LAZY value such as EventStream, it will not be started. Use compose
or flatMap
methods for that kind of thing.
Note: You still need to bind this event processor to an observer with the -->
method. Generally you should put "side effects" in the observer, but strictly speaking this is not required, and you can use --> Observer.empty
.
Note: This method is called tapEach
for consistency with Scala collections.
Attributes
Use standard bubble propagation mode. You don't need to call this unless you set useCapture
previously, and want to revert to bubbling.
Use standard bubble propagation mode. You don't need to call this unless you set useCapture
previously, and want to revert to bubbling.
See useCapture
docs here: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#usecapture
Attributes
Use capture mode
Use capture mode
Note that unlike preventDefault
config which applies to individual events, useCapture is used to install the listener onto the DOM node in the first place.
See useCapture
docs here: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#usecapture