Open DaTrader opened 4 months ago
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:
JS
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.
PS: I'll make a PR myself if I have a blessing from the core team to add this feature.
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:If the
JS
type wasn't opaque, we could do the above ourselves i.e.But since it is opaque, it'd be of great help if the pipe function was added to
JS
module.