While working on #4220, I noticed that HookInterface.pushEvent (and ViewHook.pushEvent) defines the payload type to be any, while HookInterface.pushEventTo (and ViewHook.pushEventTo) says object.
|
pushEvent(event: string, payload: any, onReply: OnReply): void; |
|
pushEventTo( |
|
selectorOrTarget: PhxTarget, |
|
event: string, |
|
payload: object, |
|
onReply: OnReply, |
|
): void; |
The Elixir/server-side code expects an Elixir map (i.e. JS object):
|
@callback handle_event(event :: binary, unsigned_params(), socket :: Socket.t()) :: |
|
{:noreply, Socket.t()} | {:reply, map, Socket.t()} |
|
@type unsigned_params :: map |
I think I tripped up on this once trying to push a non-object payload, though on the surface it feels like any JSON-serializable value could do.
Tightening up the typespec from any to object could trigger downstream warnings/errors, so flagging the inconsistence here to decide whether we any->object, object->any or do nothing.
While working on #4220, I noticed that
HookInterface.pushEvent(andViewHook.pushEvent) defines thepayloadtype to beany, whileHookInterface.pushEventTo(andViewHook.pushEventTo) saysobject.phoenix_live_view/assets/js/phoenix_live_view/view_hook.ts
Line 90 in 10e1ad5
phoenix_live_view/assets/js/phoenix_live_view/view_hook.ts
Lines 114 to 119 in 10e1ad5
The Elixir/server-side code expects an Elixir
map(i.e. JSobject):phoenix_live_view/lib/phoenix_live_view.ex
Lines 324 to 325 in 10e1ad5
phoenix_live_view/lib/phoenix_live_view.ex
Line 231 in 10e1ad5
I think I tripped up on this once trying to push a non-object payload, though on the surface it feels like any JSON-serializable value could do.
Tightening up the typespec from
anytoobjectcould trigger downstream warnings/errors, so flagging the inconsistence here to decide whether we any->object, object->any or do nothing.