MountHooks

com.raquo.laminar.api.MountHooks
trait MountHooks

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Laminar

Members list

Value members

Concrete methods

def onMountBind[El <: Base](fn: MountContext[El] => Binder[El]): Modifier[El]

Bind a subscription on mount

Bind a subscription on mount

Example usage: onMountBind(ctx => someAttr <-- someObservable(ctx)). See docs for details.

Attributes

def onMountCallback[El <: Base](fn: MountContext[El] => Unit): Modifier[El]

Execute a callback on mount. Good for integrating third party libraries.

Execute a callback on mount. Good for integrating third party libraries.

The callback runs on every mount, not just the first one.

  • Therefore, don't bind any subscriptions inside that you won't manually unbind on unmount.
  • If you fail to unbind manually, you will have N copies of them after mounting this element N times.
  • Use onMountBind or onMountInsert for that.

When the callback is called, the element is already mounted.

If you apply this modifier to an element that is already mounted, the callback will not fire until and unless it is unmounted and mounted again.

Attributes

def onMountInsert[El <: Base](fn: MountContext[El] => Inserter): Modifier[El]

Insert child node(s) on mount.

Insert child node(s) on mount.

Note: insert position is reserved as soon as this modifier is applied to the element. Basically it will insert elements in the same position, where you'd expect, on every mount.

Example usage: onMountInsert(ctx => child <-- someObservable). See docs for details.

Attributes

def onMountSet[El <: Base](fn: MountContext[El] => Setter[El]): Modifier[El]

Set a property / attribute / style on mount. Similarly to other onMount methods, you only need this when: a) you need to access MountContext b) you truly need this to only happen on mount

Set a property / attribute / style on mount. Similarly to other onMount methods, you only need this when: a) you need to access MountContext b) you truly need this to only happen on mount

Example usage: onMountSet(ctx => someAttr := someValue(ctx)). See docs for details.

Attributes

def onMountUnmountCallback[El <: Base](mount: MountContext[El] => Unit, unmount: El => Unit): Modifier[El]

Combines onMountCallback and onUnmountCallback for easier integration.

Combines onMountCallback and onUnmountCallback for easier integration.

Attributes

def onMountUnmountCallbackWithState[El <: Base, A](mount: MountContext[El] => A, unmount: (El, Option[A]) => Unit): Modifier[El]

Combines onMountCallback and onUnmountCallback for easier integration.

Combines onMountCallback and onUnmountCallback for easier integration.

  • Note that the same caveats apply as for those individual methods.
  • The mount callback returns state which will be provided to the unmount callback.
  • The unmount callback receives an Option of the state because it's possible that onMountUnmountCallbackWithState was called after the element was already mounted, in which case the mount callback defined here wouldn't have run.

Attributes

def onUnmountCallback[El <: Base](fn: El => Unit): Modifier[El]

Execute a callback on unmount. Good for integrating third party libraries.

Execute a callback on unmount. Good for integrating third party libraries.

When the callback is called, the element is still mounted.

If you apply this modifier to an element that is already unmounted, the callback will not fire until and unless it is mounted and then unmounted again.

Attributes

Concrete fields

Focus this element on mount

Focus this element on mount

Attributes