com.raquo.laminar.modifiers

Members list

Type members

Classlikes

trait Binder[-El <: Base] extends Modifier[El]

Binder is a Modifier that creates a subscription when invoked.

Binder is a Modifier that creates a subscription when invoked.

  • Note, this Modifier is NOT idempotent: Calling it N times will create and bind N subscriptions
  • onMountBind can take care of this, see the docs

Attributes

Companion
object
Supertypes
trait Modifier[El]
class Object
trait Matchable
class Any
Known subtypes
class EventListener[Ev, Out]
class KeyUpdater[El, K, V]
object Binder

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Binder.type
class CompositeKeySetter[K <: Key, -El <: Base](val key: CompositeKey[K, El], val itemsToAdd: List[String]) extends Setter[El]

This is like KeySetter, but for composite attributes like cls and role.

This is like KeySetter, but for composite attributes like cls and role.

CompositeKeySetter can not be a subtype of KeySetter because we can not implement val value – the actual value to be set is dynamic, depending on the current value of the element's composite attribute.

Also, if you call cls := "class2" after calling cls := "class1", you end up with two classes instead of just "class2", which is different fro KeySetter semantics.

Note: for dynamic subscriptions (<--), we use KeyUpdater for all keys including composite attributes.

Value parameters

itemsToAdd

Note: must be normalized (no empty strings; one value per item)

Attributes

Supertypes
trait Setter[El]
trait Modifier[El]
class Object
trait Matchable
class Any
class EventListener[Ev <: Event, Out](val eventProcessor: EventProcessor[Ev, Out], val callback: Out => Unit) extends Binder[Base]

Attributes

Companion
object
Supertypes
trait Binder[Base]
trait Modifier[Base]
class Object
trait Matchable
class Any
object EventListener

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
class KeySetter[K <: Key, V, -El <: Base](val key: K, val value: V, val action: (El, K, V) => Unit) extends Setter[El]

This class represents a modifier that sets a Key (e.g. an attribute or a style) to a specific value on a El. action is what performs this change.

This class represents a modifier that sets a Key (e.g. an attribute or a style) to a specific value on a El. action is what performs this change.

These modifiers are not only idempotent, but are also expected to be undoable, that is, calling key := value2 will override key := value1. In contrast, that is not the case for cls := "class" for example, which adds a class instead of setting it. Such cls modifiers are CompositeKeySetter, which does not extend KeySetter. // #TODO the naming of these traits is confusing...

Attributes

Companion
object
Supertypes
trait Setter[El]
trait Modifier[El]
class Object
trait Matchable
class Any
object KeySetter

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
KeySetter.type
class KeyUpdater[-El <: Base, +K <: Key, V](val key: K, val values: Observable[V], val update: (El, V, Any) => Unit) extends Binder[El]

A modifier that updates a key from a source, e.g. value <-- valueStream

A modifier that updates a key from a source, e.g. value <-- valueStream

Value parameters

update

(element, newValue, reason) => () The reason is used for updating CompositeKey-s.

Attributes

Companion
object
Supertypes
trait Binder[El]
trait Modifier[El]
class Object
trait Matchable
class Any
Self type
KeyUpdater[El, K, V]
object KeyUpdater

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
KeyUpdater.type
trait Modifier[-El <: Base]

This type represents an operation that has a side effect on a node of type El.

This type represents an operation that has a side effect on a node of type El.

For example: href := "http://example.com" is a Modifier that sets the href attribute to an example URL when invoked on an element (typically when the element is created, or if the modifier is added after the fact using the amend method, or by manually calling its apply method).

If you choose to extend this trait, make sure to understand how to use Transaction.onStart.shared. In simple cases, wrapping your callback in it similarly to Modifier.apply below will probably work. See https://github.com/raquo/Airstream/#restarting-streams-that-depend-on-signals--signalchanges-

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Inserter
trait Binder[El]
class EventListener[Ev, Out]
class KeyUpdater[El, K, V]
trait Setter[El]
class CompositeKeySetter[K, El]
class KeySetter[K, V, El]
trait ChildNode[Ref]
class CommentNode
trait ReactiveElement[Ref]
class ReactiveHtmlElement[Ref]
class ReactiveSvgElement[Ref]
class TextNode
Show all
object Modifier

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Modifier.type
trait RenderableNode[-Component]

RenderableNode[Component] is evidence that you can convert a Component to a Laminar ChildNode.

RenderableNode[Component] is evidence that you can convert a Component to a Laminar ChildNode.

If you have an implicit val of RenderableNode[Component], Laminar can render your Component-s by converting them to ChildNode-s, and will accept your Component-s in child <--, children <--, etc.

A Component must have a 1-to-1 relationship to a Laminar ChildNode. Your Component class/trait should have something like val node: ChildNode.Base or lazy val node: ChildNode.Base in it, it must not be a var or a def.

See also – RenderableText

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait RenderableSeq[-Collection[_]]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object jsArrayRenderable.type
object jsVectorRenderable.type
object laminarSeqRenderable.type
object scalaArrayRenderable.type
object sjsArrayRenderable.type
Show all
object RenderableSeq

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait RenderableText[-TextLike]

RenderableText[A] is evidence that you can convert a value of type A to a string for the purpose of rendering it as a TextNode.

RenderableText[A] is evidence that you can convert a value of type A to a string for the purpose of rendering it as a TextNode.

If you have an implicit val of RenderableText[A], Laminar can render your A type values by converting them to strings (and ultimately into com.raquo.laminar.nodes.TextNode), and will accept your values as a valid Modifier, and in child.text <--.

See also – RenderableNode

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait Setter[-El <: Base] extends Modifier[El]

This type represents a modifier that sets a "property" of an element.

This type represents a modifier that sets a "property" of an element.

It could be an html attribute, an event prop, or even a custom focus prop, the main constraint is that it should be idempotent, so that applying it several times in a row would produce the same effect as applying it once.

That way we can provide it to onMountSet { c => setter } and expect things to work if the element is mounted several times. However, note that CompositeKeySetter has special behaviour.

Attributes

Companion
object
Supertypes
trait Modifier[El]
class Object
trait Matchable
class Any
Known subtypes
class CompositeKeySetter[K, El]
class KeySetter[K, V, El]
object Setter

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Setter.type