Documentation

BX.PULL.subscribe

Description and parameters

BX.PULL.subscribe - JS method.

Subscription to Push&Pull module events. There are three formats for subscriptions, you can select a suitable format depending on your tasks.

Parameters

Parameter Description
type Subscription type ( Server, Client, Online Stand for constants:
BX.PullClient.SubscriptionType.Server,
BX.PullClient.SubscriptionType.Client,
BX.PullClient.SubscriptionType.Online
) - may be skipped, Server type is set by default.
moduleId Module that sent the command.
command Command initializing the subscription
callback Handler function

Examples of use

Subscription for all module events.

BX.PULL.subscribe({
   moduleId: 'exampleModule',
   callback: function (data) {
      if (command == 'exampleCommandOne')   {
         doSomething();
      }
      else if (command == 'exampleCommandTwo')
      {
         doSomething2();
      }
   }.bind(this)
});

Subscription to a single command

BX.PULL.subscribe({
    type: BX.PullClient.SubscriptionType.Server,
    moduleId: 'im',
    command: 'messageChat',
    callback: function (params, extra, command) {
        console.warn('Receive message:', params.message.text)
    }.bind(this)
});

Subscription to multiple commands using router function

BX.PULL.subscribe({
    type: BX.PullClient.SubscriptionType.Server,
    moduleId: 'im',
    callback: function (data) {
        if (data.command == 'messageAdd')
        {
            this.doSomething();
        }
    }.bind(this)
});

Subscription using router class

BX.PULL.subscribe(new CommandHandler(options));


User Comments

User comments are not part of official documentation. Use information provided by other users in the comments at your own risk.

The User Comments section is not to be used as a feature discussion board. Only registered users can post comments. Your comment will be visible once it has been approved by the moderator.
© «Bitrix Inc.», 2001-2021, «Bitrix Inc.», 2021