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

new way to do binding shiss #13

Open
fewkz opened this issue Apr 26, 2023 · 2 comments · May be fixed by #15
Open

new way to do binding shiss #13

fewkz opened this issue Apr 26, 2023 · 2 comments · May be fixed by #15
Labels
enhancement New feature or request

Comments

@fewkz
Copy link
Owner

fewkz commented Apr 26, 2023

What do we want? Fully typed bindings! When do we want it? NOW!
Anyways, here's what it would look like:

image

Beautiful, right? Absolutely glorious and game-changing.
Anyways, I figured out how to implement the types, so we'll be seeing it soon(er or later).
Instead of doing

local newBinding = Roact.joinBindings({binding1, binding2}):map(function(vals) 
    local v1, v2 = unpack(vals)
    return '' + v1 + ' ' + v2
end)

you get the luxury of being able to simply do:

local newBinding = froact.join(binding1, binding2).map(function(v1, v2)
    return '' + v1 + ' ' + v2
end)

Absolutely beautiful, if I do say so myself, and with full luau typing support! Everything is typed, which is not possible with the way Roact bindings are implemented.
image

@fewkz fewkz added the enhancement New feature or request label Apr 26, 2023
@fewkz
Copy link
Owner Author

fewkz commented Apr 26, 2023

This is a little complicated to implement, I also don't know what the type of Binding<T> would even be. It could be something like { getValue: () -> T }, although I think luau typing is a little finnicky when it comes to function types, so { value: T }, might be better, but you can't do .value on a binding, so we'd have to wrap bindings to make that work.

@fewkz
Copy link
Owner Author

fewkz commented Apr 27, 2023

An implementation of this is available in the https://github.com/fewkz/froact/tree/ref-binding branch

@fewkz fewkz linked a pull request May 1, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant