Skip to content

Commit

Permalink
Docs: Fix code formatting in Scaladoc
Browse files Browse the repository at this point in the history
  • Loading branch information
raquo committed Jan 16, 2025
1 parent aaa1a95 commit 30e5479
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 27 deletions.
47 changes: 27 additions & 20 deletions src/main/scala/com/raquo/laminar/keys/EventProcessor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,19 @@ class EventProcessor[Ev <: dom.Event, V](

/** Filter events by `event.target`
*
* For example, discard clicks on child <a> links with something like:
*
* div(
* onClick.filterByTarget {
* case dom.html.Anchor => false
* case _ => true
* } --> observer,
* "A bunch of clickable stuff",
* a("Some link", href("..."))
* )
* */
* For example, discard clicks on child `<a>` links with something like:
*
* {{{
* div(
* onClick.filterByTarget {
* case dom.html.Anchor => false
* case _ => true
* } --> observer,
* "A bunch of clickable stuff",
* a("Some link", href("..."))
* )
* }}}
*/
def filterByTarget(passes: dom.EventTarget => Boolean): EventProcessor[Ev, V] = {
withNewProcessor(ev => if (passes(ev.target)) processor(ev) else None)
}
Expand Down Expand Up @@ -256,18 +258,19 @@ class EventProcessor[Ev <: dom.Event, V](
*
* 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)
* {{{
* 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)
* {{{
* 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.
*
*/
def compose[Out](
operator: EventStream[V] => Observable[Out]
Expand Down Expand Up @@ -376,7 +379,9 @@ class EventProcessor[Ev <: dom.Event, V](

/** Evaluate `f` if the value was filtered out up the chain. For example:
*
* onClick.filter(isRightClick).orElseEval(_.preventDefault()) --> observer
* {{{
* 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.
Expand All @@ -391,7 +396,9 @@ class EventProcessor[Ev <: dom.Event, V](
}
}

/** (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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.scalajs.js.|
/**
* A modifier that updates a key from a source, e.g. `value <-- valueStream`
*
* @param update (element, newValue, reason) => ()
* @param update `(element, newValue, reason) => ()`
* The reason is used for updating CompositeKey-s.
*/
class KeyUpdater[-El <: ReactiveElement.Base, +K <: Key, V](
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/com/raquo/laminar/nodes/ReactiveElement.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ with ParentNode[Ref] {
*
* Structure:
*
* {{{
* Map(
* cls: List(
* "always" -> null,
Expand All @@ -92,6 +93,7 @@ with ParentNode[Ref] {
* rel: List( ... ),
* role: List( ... )
* )
* }}}
*
* Note that `mod` key can be null if the mod is not reactive, e.g. in the simple case of `cls` := "always"
* This is to avoid keeping the mod in memory after it has served its purpose.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ object ChildReceiver {
val text: ChildTextReceiver.type = ChildTextReceiver

/** Example usages:
* child(element) <-- signalOfBoolean
* child(component) <-- signalOfBoolean
* {{{
* child(element) <-- signalOfBoolean
* child(component) <-- signalOfBoolean
* }}}
*/
def apply(node: ChildNode.Base): LockedChildReceiver = {
new LockedChildReceiver(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ object ChildrenReceiver {
val command: ChildrenCommandReceiver.type = ChildrenCommandReceiver

/** Example usages:
* children(node1, node2) <-- signalOfBoolean
* children(component1, component2) <-- signalOfBoolean
* {{{
* children(node1, node2) <-- signalOfBoolean
* children(component1, component2) <-- signalOfBoolean
* }}}
*/
def apply(nodes: ChildNode.Base*): LockedChildrenReceiver = {
new LockedChildrenReceiver(laminar.Seq.from(nodes))
Expand All @@ -23,8 +25,10 @@ object ChildrenReceiver {
implicit class RichChildrenReceiver(val self: ChildrenReceiver.type) extends AnyVal {

/** Example usages:
* children(listOfNodes) <-- signalOfBoolean
* children(arrayOfComponents) <-- signalOfBoolean
* {{{
* children(listOfNodes) <-- signalOfBoolean
* children(arrayOfComponents) <-- signalOfBoolean
* }}}
*/
def apply[Collection[_], Component](
components: Collection[Component]
Expand Down

0 comments on commit 30e5479

Please sign in to comment.