action_cable 0.1.5 copy "action_cable: ^0.1.5" to clipboard
action_cable: ^0.1.5 copied to clipboard

outdated

ActionCable client port in dart, available in web, dartVM and flutter.

Pub

ActionCable in Dart #

ActionCable is the default realtime websocket framework and protocol in Rails.

This is a dart port of the client and protocol implementation, which is available in web, dartVM and flutter.

Usage #

connect #

cable = ActionCable.Connect(
  'ws://10.0.2.2:3000/cable',
  headers: {
    'Authorization': 'Some Token',
  },

  onConnected: (){
    print('connected');
  },
);

subscribe to channel #

cable.subscribeToChannel(
  'Chat', // either 'Chat' and 'ChatChannel' is fine
  channelParams: { 'id': 1 },
  onSubscribed: (){}, // `confirm_subscription` received
  onMessage: (Map message) {} // any other message received
);

unsubscribe to channel #

cable.unsubscribeToChannel(
  'Chat', // either 'Chat' and 'ChatChannel' is fine
);

perform action #

cable.performAction(
  'Chat', 'send',
  channelParams: { 'roomId': 1 },
  actionParams: { 'message': 'Hello' }
);

disconnect #

cable.disconnect();

ActionCable protocol #

Anycable has a great doc on that topic.

18
likes
25
pub points
81%
popularity

Publisher

unverified uploader

ActionCable client port in dart, available in web, dartVM and flutter.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

MIT (LICENSE)

Dependencies

web_socket_channel

More

Packages that depend on action_cable