class EventProcessor[Ev <: Event, V] extends AnyRef
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")
- Alphabetic
- By Inheritance
- EventProcessor
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new EventProcessor(eventProp: ReactiveEventProp[Ev], shouldUseCapture: Boolean = false, processor: (Ev) => Option[V])
- shouldUseCapture
(false means using bubble mode) See
useCapturedocs here: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener- 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.
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def -->[El <: Base](onNext: (V) => Unit): EventListener[Ev, V]
- Annotations
- @inline()
- def -->(sink: Sink[V]): EventListener[Ev, V]
- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def collect[V2](pf: PartialFunction[V, V2]): EventProcessor[Ev, V2]
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- val eventProp: ReactiveEventProp[Ev]
- Attributes
- protected
- def filter(passes: (V) => Boolean): EventProcessor[Ev, V]
Values that do not pass will not propagate down the chain and into the emitter.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[V2](project: (V) => V2): EventProcessor[Ev, V2]
- def mapRaw[V2](project: (Ev, Option[V]) => Option[V2]): EventProcessor[Ev, V2]
(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.
- def mapTo[V2](value: => V2): EventProcessor[Ev, V2]
Same as
map(_ => value)Same as
map(_ => value)Note:
valuewill be re-evaluated every time the event is fired - def mapToChecked: EventProcessor[Ev, Boolean]
Get the value of
event.target.checked - def mapToEvent: EventProcessor[Ev, Ev]
Get the original event.
Get the original event. You might want to call this in a chain, after some other processing.
- def mapToStrict[V2](value: V2): EventProcessor[Ev, V2]
Like mapTo, but with strict evaluation of the value
- def mapToValue: EventProcessor[Ev, String]
Get the value of
event.target.value - final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def orElseEval(f: (Ev) => Unit): EventProcessor[Ev, V]
Evaluate
fif the value was filtered out up the chain.Evaluate
fif 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.
- def preventDefault: EventProcessor[Ev, V]
Prevent default browser action for the given event (e.g.
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) - val processor: (Ev) => Option[V]
- Attributes
- protected
- def setAsChecked(implicit boolEvidence: <:<[V, Boolean]): EventProcessor[Ev, V]
Write the resulting boolean into
event.target.checked.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.
- def setAsValue(implicit stringEvidence: <:<[V, String]): EventProcessor[Ev, V]
Write the resulting string into
event.target.value.Write the resulting string into
event.target.value. You can only do this on elements that have a value property - input, textarea, select - val shouldUseCapture: Boolean
- Attributes
- protected
- def stopImmediatePropagation: EventProcessor[Ev, V]
This method prevents other listeners of the same event from being 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) - def stopPropagation: EventProcessor[Ev, V]
Propagation here refers to DOM Event bubbling or capture propagation.
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) - final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def useBubbleMode: EventProcessor[Ev, V]
Use standard bubble propagation mode.
Use standard bubble propagation mode. You don't need to call this unless you set
useCapturepreviously.See
useCapturedocs here: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener - def useCapture: EventProcessor[Ev, V]
Use capture mode (v=true) or bubble mode (v=false)
Use capture mode (v=true) or bubble mode (v=false)
Note that unlike
preventDefaultconfig which applies to individual events, useCapture is used to install the listener onto the DOM node in the first place.See
useCapturedocs here: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener - final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated