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

Lacking a way to compose a JS instance from more than two other JS instances #3233

Open
DaTrader opened this issue May 7, 2024 · 1 comment

Comments

@DaTrader
Copy link

DaTrader commented May 7, 2024

There's a use case with a pipe of three JS structs where the middle one is not known upfront and is supplied as a parameter to the function, ex:

defp make_sandwich( path, inner_js, push_opts) do
  JS.dispatch( "replace-state", detail: %{ path: path})
  |> JS.pipe( inner_js)
  |> JS.push( "do_something_useful", push_opts)
end

If the JS type wasn't opaque, we could do the above ourselves i.e.

defp pipe( first, second) do
  %JS{ first | ops: first.ops ++ second.ops}
end

But since it is opaque, it'd be of great help if the pipe function was added to JS module.

@DaTrader
Copy link
Author

DaTrader commented May 7, 2024

PS: I'll make a PR myself if I have a blessing from the core team to add this feature.

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