Skip to content

How to dip your toe in the Airstream? #100

Answered by raquo
evbo asked this question in Q&A
Discussion options

You must be logged in to vote

Your "data pipeline" will have two terminations: the source and the sink.

At the source, you want to get events into Airstream. That's easy, just create a custom stream:

val (rowStream, nextRow) = EventStream.withCallback[CsvRow]

and push events to it inside PapaParse's step function:

step = (results: js.Object, parser: js.Object) => {
  nextRow(makeCsvRow(results))
}

Now that you have a rowStream, you can map it or apply any other observable transformations. Suppose you want to accumulate some state:

val resultSignal: Signal[Result] = rowStream.foldLeft(initial = Result.empty){ (acc, nextRow) => acc.updateWithRow(nextRow) }

Finally, for the sink, you want to put your transformed data int…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@evbo
Comment options

@evbo
Comment options

Answer selected by evbo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants