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

Clojure Observable/from converts list to to an observable of a single (list) value #623

Closed
ghost opened this issue Dec 15, 2013 · 5 comments

Comments

@ghost
Copy link

ghost commented Dec 15, 2013

I'm trying out the clojure example code and the results seem wrong.

With the following:

(defn hello
  [& args]
  (-> (Observable/from args)
    (.subscribe (rx/action [v] (println (str "Hello " v "!"))))))

(hello "Ben" "George")

I expected the observable to emit two distinct values, "Ben" and "George", before completing, resulting in one line of output per name.

However, the repl output is:

Hello ("Ben" "George")!

So it seems the entire args list is emitted as a single value.

Tried 0.15.1 as well as current master at 7ec374c. clojure 1.5.1.

@ghost
Copy link
Author

ghost commented Dec 15, 2013

(defn hello
  [& args]
  (-> (Observable/from  '("Ben" "George") ) ; hardcode the list
    (.subscribe (rx/action [v] (println (str "Hello " v "!"))))))

(hello "Ben" "George")

Works fine. Very strange.

@daveray
Copy link
Contributor

daveray commented Dec 15, 2013

The Clojure compiler has many versions of Observable/from to choose from and here it picks the wrong one. You'll need to give it a hint:

(Observable/from ^java.lang.Iterable args)

that should do it.

@ghost
Copy link
Author

ghost commented Dec 15, 2013

Thanks, that works. Not cool though, it's reasonable to expect it to just work.

@daveray
Copy link
Contributor

daveray commented Dec 15, 2013

Welcome to Java interop with dynamic types.

@daveray daveray closed this as completed Dec 15, 2013
@ghost
Copy link
Author

ghost commented Dec 15, 2013

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant