icecap

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?

Showing Posts 1 to 2

chrismccord

chrismccord

Creator of Phoenix

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 override channel.onMessage and handle it there the same way.

icecap

icecap OP

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…?)

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Alvinkariuki
How Can I Optimise Compile Time Dependencies I have been building an elixir application for about 2 years now. Many modules and files ha...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New

Other Trending Topics Top

mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews