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

Composing with Functions - Feature request. #5

Closed
sirinath opened this issue Feb 10, 2014 · 5 comments
Closed

Composing with Functions - Feature request. #5

sirinath opened this issue Feb 10, 2014 · 5 comments

Comments

@sirinath
Copy link

Is it possible to have ability to map multiple Vars to be redirected to a function. When all the parameters a variable the function is called and results passed on.

@lihaoyi
Copy link
Owner

lihaoyi commented Feb 10, 2014

Uhh you mean like this

import rx._
val a = Var(1); val b = Var(2)
val c = Rx{ a() + b() }
println(c()) // 3
a() = 4
println(c()) // 6

@lihaoyi lihaoyi closed this as completed Feb 10, 2014
@sirinath
Copy link
Author

What I meant is

import rx._

val f = (a: Int, b: Int) => a + b

val f1 = Fun(f)

val a = Var(1); val b = Var(2)
val c = Rx{ f1(a, b) }

println(c()) // 3
a() = 4
println(c()) // 6

f can be any function I want to re use. I don't see why you closed this.

@lihaoyi
Copy link
Owner

lihaoyi commented Feb 10, 2014

I closed it because it already works. Did you even try it?

@sirinath
Copy link
Author

Not yet. I was going through the docs. It was silent on how to integrate existing code in the middle of a dataflow. I thought this did not exist. Any way the initial code you have given above also does not show how to pipe variable a and b into an existing function keep passing this into other rx variables which might be other functions.

@lihaoyi
Copy link
Owner

lihaoyi commented Feb 10, 2014

Well, go try it, it works. At least try out the features which exist before making a feature request!

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

2 participants