phoenix_live_view
phoenix_live_view copied to clipboard
Lacking a way to compose a `JS` instance from more than two other `JS` instances
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.