Introducing Magic Socket 1.0.1
Real-time channels, ready in your Magic app.
Real-time broadcasting for Magic apps through the Echo facade, with a Reverb driver and a null driver. Built for a Reverb or other Pusher-protocol server; the API will look familiar to Laravel Echo users.
One facade. Every channel.
Call Echo to listen on public, private and presence channels. The driver you select in broadcasting.default handles the connection.
-
Three channel types
Learn more about Three channel typesEcho.channel(name)for public,Echo.private(name)for private (auth through/broadcasting/auth) andEcho.join(name)for presence, withmembers,onJoin,onLeave. -
Reconnects on its own
The Reverb driver reconnects with exponential backoff and jitter and resubscribes every channel after each handshake, so a dropped connection heals without app code.
Learn more about Reconnects on its own -
Pick a driver
Learn more about Pick a driverbroadcasting.defaultselectsreverbfor a Reverb or Pusher-protocol server. The defaultnulldriver does nothing, so an app without a socket server runs unchanged. -
Skip the sender
While a socket is connected and
Learn more about Skip the senderNetworkServiceProvideris registered, an HTTP interceptor addsX-Socket-IDto each request, so the server'stoOthers()skips the sender.Echo.socketIdreads it. -
Listen in controllers
The
Learn more about Listen in controllersListensToBroadcastsmixin lets aMagicControllerlisten on a private channel and clean up with the controller (BroadcastListeners.channel). -
Test without a socket
Learn more about Test without a socketEcho.fake()swaps inFakeBroadcastManagerso a test asserts subscriptions and listeners without a socket, andEcho.unfake()restores it.
Add it in seconds
Or add to pubspec.yaml:
dependencies:
magic_socket: ^1.0.1
Or give your AI agent this prompt: