com.raquo.airstream.split

Type members

Classlikes

class DuplicateKeysConfig(var _shouldWarn: Boolean)

.split() operator does not tolerate duplicate keys, i.e. the Seq you provide it must not contain records that have the same key(record).

.split() operator does not tolerate duplicate keys, i.e. the Seq you provide it must not contain records that have the same key(record).

However, checking for duplicate keys can get expensive when splitting very large lists, so this setting can be used to disable the checks.

When warnings are enabled, YOUR CODE WILL STILL BREAK if the .split() operator encounters duplicate keys, but it will first print a warning in the browser console listing the duplicate keys at fault.

We enable this setting by default to aid in debugging. As the end user, you might want to disable this either globally or for specific .split() usages to improve performance on very large lists.

#TODO[Docs]: Add a short section to the docs about this.

#TODO: Add more granular control later, if there is demand for that. For example, we could instruct Airstream to skip duplicate keys, or to raise an exception if a duplicate happens. In the latter case perhaps we could do that by catching the right exception, without the overhead of checking for duplicates. But not sure how bulletproof that logic would be.

Companion:
object
Companion:
class

If changing the order, check it first on all Scala versions (and be disappointed). Some of the errors caused by implicit ambiguity are not very deterministic in Scala 3. Be conservative.

If changing the order, check it first on all Scala versions (and be disappointed). Some of the errors caused by implicit ambiguity are not very deterministic in Scala 3. Be conservative.

class SplitSignal[M[_], Input, Output, Key](val parent: Signal[M[Input]], key: Input => Key, distinctCompose: Signal[Input] => Signal[Input], project: (Key, Input, Signal[Input]) => Output, splittable: Splittable[M], duplicateKeysConfig: DuplicateKeysConfig) extends SingleParentSignal[M[Input], M[Output]]

Broadly similar to parent.map(_.map(project)), but the project part gets access to more data and is memoized by key.

Broadly similar to parent.map(_.map(project)), but the project part gets access to more data and is memoized by key.

See docs.

Value parameters:
distinctCompose

Transformation to apply to each key's input stream before providing it to project - Usually you want _.distinct here, so that each of the streams is only triggered when the input for its key actually changes (otherwise they would get an update every time that the parent stream emitted)

key

A sort of grouping / memoization key for inputs in parent

project

(key, initialInput, inputChangesForThisKey) => output - Will only be called ONCE for a given key as long as parent contains an Input for this Key - Updates to Input with this Key will be published in inputChangesForThisKey - After parent stops containing an Input for this Key, we forget we ever called project for this key

trait Splittable[M[_]]

The split operator needs an implicit instance of Splittable[M] in order to work on observables of M[_]

The split operator needs an implicit instance of Splittable[M] in order to work on observables of M[_]

Companion:
object
final class SplittableOneSignal[Input](val signal: Signal[Input]) extends AnyVal
final class SplittableOneStream[Input](val stream: EventStream[Input]) extends AnyVal
final class SplittableOptionSignal[Input](val signal: Signal[Option[Input]]) extends AnyVal
final class SplittableOptionStream[Input](val stream: EventStream[Option[Input]]) extends AnyVal
final class SplittableSignal[M[_], Input](val signal: Signal[M[Input]]) extends AnyVal
final class SplittableStream[M[_], Input](val stream: EventStream[M[Input]]) extends AnyVal