Reputation: 73609
I am starting to create a web-app in phoenix. I had looked at few of the tutorials as well as creating chat example from chrismccord. When we generate ecto
models, they generate CRUD web pages using controller, which works for a simple purpose and not for realtime updates. I am little bit confused when to use controllers and when to use channels, is it only when real-time updates are required?
Also is there a way to use both together for a particular form/webpage, where certain tasks are done on controllers and certain in channel. Please clarify.
Upvotes: 1
Views: 467
Reputation: 11278
Channels are for real-time communication. Controllers are for normal HTTP request-response communication.
Controllers are often based on database resources, so the usual CRUD operations are generated for you. But the use cases for real-time are more varied. I don't think there is anything that could be considered a default implementation to produce by the generator.
You can definitely use both channels for real-time updates and regular controllers within one page, but you need to write the code for channels yourself.
Upvotes: 1