Closed maharjanaman closed 5 years ago
Yup, it supports react-native (and I have tested and used it personally for my apps).
And since this is agnostic to whether you use react or react-native, I did not mention specifically in the docs that you can use it with react-native.
createCable = (jwt) => {
if(this.cable && this.cable.jwt == jwt) return;
this.cable = ActionCable.createConsumer("ws://localhost:8000/cable", jwt);
this.subscription = this.cable.subscriptions.create({channel: "OrderChannel"}, {
connected: ()=> { console.log("cable: connected"); SnackBar.show("Connected", { confirmText:"Dismiss", onConfirm: ()=>SnackBar.dismiss()}); },
disconnected: ()=> { console.log("cable: disconnected"); SnackBar.show("Disconnected", { confirmText:"Dismiss", onConfirm: ()=>SnackBar.dismiss()}); },
received: (data) => {
console.log('yey, received data!');
SnackBar.show("Received Data!", { confirmText:"Dismiss", onConfirm: ()=>SnackBar.dismiss()});
}
}
)
};
Then you can call createCable(jwt)
once you have the JWT. Let me know if you have any problems.
Is there a way to implement this in react native???