How to use the @rails/actioncable.createConsumer function in @rails/actioncable

To help you get started, we’ve selected a few @rails/actioncable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ruby-china / homeland / app / javascript / homeland / index.js View on Github external
require("jquery.mobile-events");
require("vendor/social-share-button");

import { createConsumer } from "@rails/actioncable";

window.App = {
  turbolinks: false,
  mobile: false,
  locale: "zh-CN",
  notifier: null,
  current_user_id: null,
  access_token: "",
  asset_url: "",
  twemoji_url: "https://twemoji.maxcdn.com/",
  root_url: "",
  cable: createConsumer(),

  isLogined() {
    return document.getElementsByName("current-user").length > 0;
  },

  loading() {
    return console.log("loading...");
  },

  fixUrlDash(url) {
    return url.replace(/\/\//g, "/").replace(/:\//, "://");
  },

  // 警告信息显示, to 显示在那个 DOM 前 (可以用 css selector)
  alert(msg, to) {
    $(".alert").remove();
github locoframework / loco-rails / test / dummy / frontend / js / initializers / loco.js View on Github external
import Article from "models/Article";
import Comment from "models/article/Comment";
import Member from "models/room/Member";
import Room from "models/Room";
import User from "models/User";

import Admin from "controllers/Admin";
import Main from "controllers/Main";
import UserController from "controllers/User";

Article.Comment = Comment;
Room.Member = Member;

init({
  cable: createConsumer(),
  controllers: {
    Admin,
    Main,
    User: UserController
  },
  models: {
    Article,
    Room,
    User
  },
  notificationCenter: NotificationCenter,
  notifications: {
    log: true,
    size: 10
  },
  postInit: () => {
github gitlabhq / gitlabhq / spec / frontend / sidebar / assignees_realtime_spec.js View on Github external
it('calls create subscription', () => {
      const cable = ActionCable.createConsumer();

      createComponent();

      return wrapper.vm.$nextTick().then(() => {
        expect(cable.subscriptions.create).toHaveBeenCalledTimes(1);
        expect(cable.subscriptions.create).toHaveBeenCalledWith(
          {
            channel: 'IssuesChannel',
            iid: wrapper.props('issuableIid'),
            project_path: wrapper.props('projectPath'),
          },
          { received: wrapper.vm.received },
        );
      });
    });
  });
github gitlabhq / gitlabhq / app / assets / javascripts / actioncable_consumer.js View on Github external
import { createConsumer } from '@rails/actioncable';
import ConnectionMonitor from './actioncable_connection_monitor';

const consumer = createConsumer();

if (consumer.connection) {
  consumer.connection.monitor = new ConnectionMonitor(consumer.connection);
}

export default consumer;
github anycable / anycable_rails_demo / frontend / utils / cable.js View on Github external
export const createCable = () => {
  if (!consumer) {
    consumer = createConsumer();
  }

  return consumer;
}

@rails/actioncable

WebSocket framework for Ruby on Rails.

MIT
Latest version published 9 days ago

Package Health Score

92 / 100
Full package analysis

Popular @rails/actioncable functions