Is a json channel api the right path

Hi,

I’m rather new to this stuff and out of pure interest I’ve started building a rather simple spa and have come to a point where everything is working fine but I’m beginning to consider if I’m heading down the right path design wise.

As of now I connect the user to a channel at login and then communicate in json. At handle_in/3 I basically take the event, data and then forward it to another module where I spread it out to different controllers to generate the response.
I’ve come to realize that, apart from the channel, I just built another router to an api just as I would anywhere else. Perhaps I’m i heading down the wrong path just rebuilding the same general thing but with a new syntax.

As i see it I get to have a nice fast interaction with no real use for session tokens etc.

Is this a good approach or just stupid? What is the best way to build this the elixir way?

(Right now I’m in no actual need of the ability to have multiple users on the same channel)

:wave:

What exactly you don’t like about your approach? Apart from its similarity to something you’ve built before …

Perhaps I’m i heading down the wrong path just rebuilding the same general thing but with a new syntax.

Ok.
As stated I’m quite new to this and I do like the approach. I just wanted to have a reality check as I have not seen any examples do it this way. It could just have been that I did misunderstand stuff or was reinventing another wheel.

I think it’s a fine way to do things.

I think eventually we’re going to see some common libraries & practices emerge around this way of doing things. When that happens someone in your position will use the shiny new “channel router” instead of feeling like he’s reimplementing router, while the rest of us (you included at that point) will sigh and wish we had the time to refactor to use the new one.

(Aside, the first time I typed “shiny” above I accidentally hit the “t” instead of “n”…)

3 Likes

Thanks,

Now there is at least one place that confirms that the chat example is not the only use of the cannels :slight_smile: