Skip to content

Commit

Permalink
scan default value
Browse files Browse the repository at this point in the history
  • Loading branch information
m1dnight committed May 10, 2018
1 parent d60b2f5 commit efa81ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/obs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ defmodule Observables.Obs do
More information: http://reactivex.io/documentation/operators/scan.html
"""
def scan({observable_fn, _parent_pid}, f) do
{:ok, pid} = GenObservable.start_link(Scan, [f])
def scan({observable_fn, _parent_pid}, f, default \\ nil) do
{:ok, pid} = GenObservable.start_link(Scan, [f, default])

observable_fn.(pid)

Expand Down
4 changes: 2 additions & 2 deletions lib/observables/scan.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ defmodule Observables.Scan do
@moduledoc false
use Observables.GenObservable

def init([proc]) do
def init([proc, default]) do
Logger.debug("Scan: #{inspect(self())}")
# We don't keep state in merge.
{:ok, %{:proc => proc, :intermediate => nil}}
{:ok, %{:proc => proc, :intermediate => default}}
end

def handle_event(v, %{:proc => proc, :intermediate => i}) do
Expand Down

0 comments on commit efa81ee

Please sign in to comment.