Package

org.querki.gadgets

core

Permalink

package core

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. core
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait Gadget[Output <: Element] extends ManagedFrag[Output]

    Permalink

    Wrapper around Scalatags, to provide support for tracking and updating the rendered elements as the underlying data changes.

    Wrapper around Scalatags, to provide support for tracking and updating the rendered elements as the underlying data changes.

    If you need complex behaviour, subclass this and extend it. If you just need to be able to access the DOM created by the rendered Scalatags, just use the Gadget(scalatags) entry point.

  2. class GadgetElementRef[T <: Element] extends GadgetRef[Gadget[T]]

    Permalink

    A variant of GadgetRef, which you should use when you're just dealing with a raw TypedTag, not a Gadget per se.

    A variant of GadgetRef, which you should use when you're just dealing with a raw TypedTag, not a Gadget per se.

    All this really does is provide type-safety for this situation, without requiring that GadgetRef itself know about T.

    Create this using GadgetRef.of[].

  3. trait GadgetNotifier[T] extends AnyRef

    Permalink

    This typeclass is used to express the notion of something that can receive notifications from Gadgets.

  4. class GadgetRef[G <: Gadget[_]] extends Gadget[Element]

    Permalink

    A reactive wrapper around Gadgets, to make them a bit easier to use.

    A reactive wrapper around Gadgets, to make them a bit easier to use.

    Think of this as a reactive container into which you put a Gadget of a particular type, which other code can hang off of. This is how you build complex reactive structures, while still keep the declarations of the Gadgets in the Scalatags hierarchy so that you can see what goes where.

    So you typically declare this as an empty holder, and then assign to it later in the Scalatags, like this:

    val myGadget = GadgetRef[MyGadget]
    
    def funcUsingMyGadget = {
      myGadget.someFunction()
    }
    
    def funcUsingMyGadgetIfExists = {
      myGadget.map(_.someOtherFunction())
    }
    ...
    val rendered =
      p(
        "Here's the gadget",
        myGadget <= new MyGadget(...)
      )

    Note that the GadgetRef will implicitly unwrap to the underlying Gadget if the environment calls for that. Use that with some care -- it will throw an exception if the Gadget hasn't been set yet! If you aren't certain whether the Gadget has been set, use map() or flatMap() instead, and it has Option-like semantics.

    You don't usually create this by hand -- use the methods in the companion object to make GadgetRef and GadgetElementRef.

    TODO: is there any way to make this sensitive to the actual element type of the Gadget, without forcing us to add another type parameter everywhere?

    TODO: this is annoyingly dependent on jQuery. Add the necessary bits to sQuery, so we can remove the jQuery dependencies.

  5. trait ManagedFrag[Output <: Node] extends Frag

    Permalink

    A controlled wrapper around a Scalatags Frag, which gives you access to the lifecycle and the resulting DOM objects.

    A controlled wrapper around a Scalatags Frag, which gives you access to the lifecycle and the resulting DOM objects.

    IMPORTANT: unlike pure ScalaTags, the Gadgets library assumes that Frags are single-use! That is, in conventional ScalaTags you can create a Frag or TypedTag and render it over and over, getting a new Node each time. By contrast, rendering a ManagedFrag records the resulting Node in its elemOptRx (also exposed as elemOpt or simply elem), and you are encouraged to use the rendered method instead if there is any risk of accessing it multiple times -- the idea is that you create a separate Frag for each bit, and render that once.

    Note that a ManagedFrag corresponds to a DOM *Node*, which is almost anything: an Element, an Attribute, a Text, etc. A Gadget (which is a subclass of ManagedFrag) corresponds to a DOM Element.

    In and of itself, ManagedFrag is a bit weak, but it is the basis of multiple forms of useful gadgetry.

  6. class SimpleGadget extends Gadget[Element]

    Permalink

    This variant of Gadget is particularly useful when you're not trying to do anything complex, just have a handle to the resulting elem.

    This variant of Gadget is particularly useful when you're not trying to do anything complex, just have a handle to the resulting elem. Usually accessed as Gadget(...).

  7. class TypedGadget[Output <: Element] extends Gadget[Output]

    Permalink

    Wrapper around a TypedTag.

    Wrapper around a TypedTag. You don't need to specify this explicitly -- there is an implicit def in globals that transforms TypedTag into TypedGadget.

Value Members

  1. object Gadget

    Permalink
  2. object GadgetLookup

    Permalink

    These functions deal with mapping from Elements back to their Gadgets.

  3. object GadgetRef

    Permalink
  4. implicit def tag2Gadget[Output <: Element](guts: TypedTag[Output]): Gadget[Output]

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped