icecap
I need to camelize channel payloads for js purposes
I have tried 2 options so far, 1- writing a custom serializer and 2- wrapping Jason and passing it to json_library in config
In both cases, presence diffs and fields like phx_ref get camelized, which is probably not a good thing (or does it not matter?). One option is to figure out how to target and skip those, but since they are transported via the same means as app payloads, I’m guessing this would involve some hacky matching procedure, which does not seem too idiomatic.
I have read this article which basically describes the serializer approach, and has the downside mentioned above.
Surely many of you have been thru this, this can’t be that niche of a case (pun)
What is an idiomatic approach to camelizing channel payloads?
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
chrismccord
you can do it selectively on the client with your own serializer and delegate to ours for the decoding, then rewrite the payload keys unless the event starts with
phx. You could also overridechannel.onMessageand handle it there the same way.icecap
thanks for the answer!
Which decoder do you mean by “ours”?
Also are there any snake_cased params used internally by
phoenix.js? As in, if they’re only used by the server, is it safe to just camelize all ouput and underscore all input ?I’d like to keep the serialization server side, as I will have > 1 clients. (Or are there caveats to that…?)