sacketty / nativescript-actioncable

Rails ActionCable ported to nativescript
MIT License
1 stars 2 forks source link

Failed to find module: "nativescript-actioncable" #1

Closed viniciodeltoro closed 7 years ago

viniciodeltoro commented 7 years ago

Hey,

I'm trying to use this module in my Nativescript app but I get an error screen when the app gets opened. screenshot_1490561026

I installed the node package by typing 'npm install nativescript-actioncable' and followed the example code located in 'nativescript-actioncable/demo/app/app.component.ts'. My code looks like this:

import { Injectable } from "@angular/core";
var config = require("../../shared/config");
require("nativescript-actioncable");
import { Chat } from "../../models/chat/chat";
import { Message } from "../../models/chat/message";

@Injectable()
export class ChatCommunicationService {
  private socketURL: string;
  private cable: any;
  private room: any;

  constructor() {
    global.ActionCable.startDebugging();
  }

  public initChatCommunicationService() {
    this.socketURL = config.apiUrl + "/v1/cable";
    this.cable = global.ActionCable.createConsumer(this.socketURL);
    this.room = this.cable.subscriptions.create("ChatChannel", {
      connected: () => {
        console.log("connected to MessageChannel");
      },
      diconnected: () => {
        console.log('diconnected from MessageChannel');
      },
      received: (data) => {
        console.log("received data " + JSON.stringify(data));
      }
    });
  }

  public sendChatData(data: any) {
    this.room.speak = (message) => {
      return this.room.perform('speak', { message: message });
    }
  }
}

If anyone knows how to fix this please let me know. Thanks

viniciodeltoro commented 7 years ago

I fixed it by running 'npm install nativescript-actioncable --save' and then, 'tns platfrom remove android', and then 'tns platform add android', and then tns run android.