Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update after executing <~ #52

Open
pszot-concise opened this issue Aug 7, 2015 · 1 comment
Open

Update after executing <~ #52

pszot-concise opened this issue Aug 7, 2015 · 1 comment
Labels

Comments

@pszot-concise
Copy link

let stream = Stream.once("foo").ownedBy(self)
println <~ stream
println <~ stream

I wonder if it's correct behaviour, that println will be called once. If I now did something like:

(label,"text") <~ stream

The label would never change.

@inamiy
Copy link
Member

inamiy commented Aug 8, 2015

Yes, that's correct behavior.
Stream.once("foo") will send value once and complete immediately when first <~ is triggered because <~ works for both binding and firing.

There are several approaches to your desired behavior:

  1. Use Stream.once("foo") |> delay(0) to delay firing until next run loop.

  2. Create new stream for each println.

    let createStream: Void -> Stream<String> = { return Stream.once("foo").ownedBy(self) }
    println <~ createStream()
    println <~ createStream()
  3. Use stream.progress(println) instead of <~.
    (Maybe, there should have some new binding only operator like below)

    let stream = Stream.once("foo").ownedBy(self)
    
    stream.progress(println)
    //println <~| stream   // `<~|` as binding only (not included in ver 0.12.x)
    
    println <~ stream    // `<~` as binding + fire

@inamiy inamiy added the question label Aug 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants