Skip to content

Streaming Jobs

Dimitrios Zorbas edited this page Nov 23, 2016 · 1 revision

To broadcast data to your widgets from streaming APIs like Twitter, you can use a regular job without an interval.

Example:

Code adapted from: https://github.com/kittoframework/demo/blob/master/jobs/twitter.ex#L10

job :twitter_streaming do
  spawn_link fn ->
    for tweet <- ExTwitter.stream_filter(track: "linux") do
      broadcast!(:twitter_linux, %{text: tweet.text})
    end
  end
end

This will emit a new twitter_linux event for each tweet streamed from the Twitter client.