Constructor
new VivochaBus()
Internal constructor, not to be used directly.
Extends
- EventEmitter
Members
services
Dictionary of the currently available services. Each key is a service id and the corresponding value is the service provider.
services
Dictionary of the currently available services. Each key is a service id and the corresponding value is the service provider.
services
Dictionary of the currently available services. Each key is a service id and the corresponding value is the service provider.
services
Dictionary of the currently available services. Each key is a service id and the corresponding value is the service provider.
services
Dictionary of the currently available services. Each key is a service id and the corresponding value is the service provider.
services
Dictionary of the currently available services. Each key is a service id and the corresponding value is the service provider.
Methods
registerService(id, provider)
Register a service provider on the bus: all users of the bus will be able to access the service.
Registered services are available through the property services
or the method
request
.
Examples
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.registerService("HelloWorld", {
greet: function(name) {
// Note that even if this function is synchronous
// it'll return a Promise when accessed throught the Bus
return "Hello, " + (name || "World") + "!";
}
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.on("added", function(id, provider) {
console.log('service ' + id + ' is now available');
// provider can be used directly
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.on("added.HelloWorld", function(provider) {
provider.greet().then(function(greeting) {
console.log(greeting); // Prints "Hello, World!"
});
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.services.HelloWorld.greet().then(function(greeting) {
console.log(greeting); // Prints "Hello, World!"
});
});
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Unique identifier of the service being added. |
provider |
object | Objected implementing the service being offered through the bus. |
unregisterService(id)
Deregister a previously registered service. Only the bus user that registered the service can deregister it.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Identifier of the service to deregister. |
request(id, method, …argsopt) → {Promise}
Invoke a method on a registered service. Similar to calling vivocha.bus.id.method(...args)
, but checks that
service and method are available.
Example
vivocha.bus.request('HelloWorld', 'greet', 'John').then(function(greeting) {
console.log(greeting); // Prints "Hello, John!"
});
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | Identifier of the service to invoke a method upon. |
|
method |
string | Name of the method to invoke. |
|
args |
* |
<optional> <repeatable> |
Method arguments |
Returns:
- Type
- Promise
registerService(id, provider)
Register a service provider on the bus: all users of the bus will be able to access the service.
Registered services are available through the property services
or the method
request
.
Examples
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.registerService("HelloWorld", {
greet: function(name) {
// Note that even if this function is synchronous
// it'll return a Promise when accessed throught the Bus
return "Hello, " + (name || "World") + "!";
}
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.on("added", function(id, provider) {
console.log('service ' + id + ' is now available');
// provider can be used directly
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.on("added.HelloWorld", function(provider) {
provider.greet().then(function(greeting) {
console.log(greeting); // Prints "Hello, World!"
});
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.services.HelloWorld.greet().then(function(greeting) {
console.log(greeting); // Prints "Hello, World!"
});
});
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Unique identifier of the service being added. |
provider |
object | Objected implementing the service being offered through the bus. |
unregisterService(id)
Deregister a previously registered service. Only the bus user that registered the service can deregister it.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Identifier of the service to deregister. |
request(id, method, …argsopt) → {Promise}
Invoke a method on a registered service. Similar to calling vivocha.bus.id.method(...args)
, but checks that
service and method are available.
Example
vivocha.bus.request('HelloWorld', 'greet', 'John').then(function(greeting) {
console.log(greeting); // Prints "Hello, John!"
});
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | Identifier of the service to invoke a method upon. |
|
method |
string | Name of the method to invoke. |
|
args |
* |
<optional> <repeatable> |
Method arguments |
Returns:
- Type
- Promise
registerService(id, provider)
Register a service provider on the bus: all users of the bus will be able to access the service.
Registered services are available through the property services
or the method
request
.
Examples
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.registerService("HelloWorld", {
greet: function(name) {
// Note that even if this function is synchronous
// it'll return a Promise when accessed throught the Bus
return "Hello, " + (name || "World") + "!";
}
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.on("added", function(id, provider) {
console.log('service ' + id + ' is now available');
// provider can be used directly
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.on("added.HelloWorld", function(provider) {
provider.greet().then(function(greeting) {
console.log(greeting); // Prints "Hello, World!"
});
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.services.HelloWorld.greet().then(function(greeting) {
console.log(greeting); // Prints "Hello, World!"
});
});
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Unique identifier of the service being added. |
provider |
object | Objected implementing the service being offered through the bus. |
unregisterService(id)
Deregister a previously registered service. Only the bus user that registered the service can deregister it.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Identifier of the service to deregister. |
request(id, method, …argsopt) → {Promise}
Invoke a method on a registered service. Similar to calling vivocha.bus.id.method(...args)
, but checks that
service and method are available.
Example
vivocha.bus.request('HelloWorld', 'greet', 'John').then(function(greeting) {
console.log(greeting); // Prints "Hello, John!"
});
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | Identifier of the service to invoke a method upon. |
|
method |
string | Name of the method to invoke. |
|
args |
* |
<optional> <repeatable> |
Method arguments |
Returns:
- Type
- Promise
registerService(id, provider)
Register a service provider on the bus: all users of the bus will be able to access the service.
Registered services are available through the property services
or the method
request
.
Examples
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.registerService("HelloWorld", {
greet: function(name) {
// Note that even if this function is synchronous
// it'll return a Promise when accessed throught the Bus
return "Hello, " + (name || "World") + "!";
}
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.on("added", function(id, provider) {
console.log('service ' + id + ' is now available');
// provider can be used directly
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.on("added.HelloWorld", function(provider) {
provider.greet().then(function(greeting) {
console.log(greeting); // Prints "Hello, World!"
});
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.services.HelloWorld.greet().then(function(greeting) {
console.log(greeting); // Prints "Hello, World!"
});
});
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Unique identifier of the service being added. |
provider |
object | Objected implementing the service being offered through the bus. |
unregisterService(id)
Deregister a previously registered service. Only the bus user that registered the service can deregister it.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Identifier of the service to deregister. |
request(id, method, …argsopt) → {Promise}
Invoke a method on a registered service. Similar to calling vivocha.bus.id.method(...args)
, but checks that
service and method are available.
Example
vivocha.bus.request('HelloWorld', 'greet', 'John').then(function(greeting) {
console.log(greeting); // Prints "Hello, John!"
});
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | Identifier of the service to invoke a method upon. |
|
method |
string | Name of the method to invoke. |
|
args |
* |
<optional> <repeatable> |
Method arguments |
Returns:
- Type
- Promise
registerService(id, provider)
Register a service provider on the bus: all users of the bus will be able to access the service.
Registered services are available through the property services
or the method
request
.
Examples
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.registerService("HelloWorld", {
greet: function(name) {
// Note that even if this function is synchronous
// it'll return a Promise when accessed throught the Bus
return "Hello, " + (name || "World") + "!";
}
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.on("added", function(id, provider) {
console.log('service ' + id + ' is now available');
// provider can be used directly
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.on("added.HelloWorld", function(provider) {
provider.greet().then(function(greeting) {
console.log(greeting); // Prints "Hello, World!"
});
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.services.HelloWorld.greet().then(function(greeting) {
console.log(greeting); // Prints "Hello, World!"
});
});
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Unique identifier of the service being added. |
provider |
object | Objected implementing the service being offered through the bus. |
unregisterService(id)
Deregister a previously registered service. Only the bus user that registered the service can deregister it.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Identifier of the service to deregister. |
request(id, method, …argsopt) → {Promise}
Invoke a method on a registered service. Similar to calling vivocha.bus.id.method(...args)
, but checks that
service and method are available.
Example
vivocha.bus.request('HelloWorld', 'greet', 'John').then(function(greeting) {
console.log(greeting); // Prints "Hello, John!"
});
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | Identifier of the service to invoke a method upon. |
|
method |
string | Name of the method to invoke. |
|
args |
* |
<optional> <repeatable> |
Method arguments |
Returns:
- Type
- Promise
registerService(id, provider)
Register a service provider on the bus: all users of the bus will be able to access the service.
Registered services are available through the property services
or the method
request
.
Examples
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.registerService("HelloWorld", {
greet: function(name) {
// Note that even if this function is synchronous
// it'll return a Promise when accessed throught the Bus
return "Hello, " + (name || "World") + "!";
}
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.on("added", function(id, provider) {
console.log('service ' + id + ' is now available');
// provider can be used directly
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.on("added.HelloWorld", function(provider) {
provider.greet().then(function(greeting) {
console.log(greeting); // Prints "Hello, World!"
});
});
});
// Wait for the library to be ready
vivocha.ready().then(function() {
vivocha.bus.services.HelloWorld.greet().then(function(greeting) {
console.log(greeting); // Prints "Hello, World!"
});
});
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Unique identifier of the service being added. |
provider |
object | Objected implementing the service being offered through the bus. |
unregisterService(id)
Deregister a previously registered service. Only the bus user that registered the service can deregister it.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Identifier of the service to deregister. |
request(id, method, …argsopt) → {Promise}
Invoke a method on a registered service. Similar to calling vivocha.bus.id.method(...args)
, but checks that
service and method are available.
Example
vivocha.bus.request('HelloWorld', 'greet', 'John').then(function(greeting) {
console.log(greeting); // Prints "Hello, John!"
});
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | Identifier of the service to invoke a method upon. |
|
method |
string | Name of the method to invoke. |
|
args |
* |
<optional> <repeatable> |
Method arguments |
Returns:
- Type
- Promise
Events
added
A new service is available.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The id of the new service. |
provider |
object | A reference to the service provider object. |
added∙SERVICE_ID
A new service called SERVICE_ID is available.
Parameters:
Name | Type | Description |
---|---|---|
provider |
object | A reference to the service provider object. |
removed
A service is no longer available.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The id of the service. |
removed∙SERVICE_ID
The service SERVICE_ID is no longer available.
added
A new service is available.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The id of the new service. |
provider |
object | A reference to the service provider object. |
added∙SERVICE_ID
A new service called SERVICE_ID is available.
Parameters:
Name | Type | Description |
---|---|---|
provider |
object | A reference to the service provider object. |
removed
A service is no longer available.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The id of the service. |
removed∙SERVICE_ID
The service SERVICE_ID is no longer available.
added
A new service is available.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The id of the new service. |
provider |
object | A reference to the service provider object. |
added∙SERVICE_ID
A new service called SERVICE_ID is available.
Parameters:
Name | Type | Description |
---|---|---|
provider |
object | A reference to the service provider object. |
removed
A service is no longer available.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The id of the service. |
removed∙SERVICE_ID
The service SERVICE_ID is no longer available.
added
A new service is available.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The id of the new service. |
provider |
object | A reference to the service provider object. |
added∙SERVICE_ID
A new service called SERVICE_ID is available.
Parameters:
Name | Type | Description |
---|---|---|
provider |
object | A reference to the service provider object. |
removed
A service is no longer available.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The id of the service. |
removed∙SERVICE_ID
The service SERVICE_ID is no longer available.
added
A new service is available.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The id of the new service. |
provider |
object | A reference to the service provider object. |
added∙SERVICE_ID
A new service called SERVICE_ID is available.
Parameters:
Name | Type | Description |
---|---|---|
provider |
object | A reference to the service provider object. |
removed
A service is no longer available.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The id of the service. |
removed∙SERVICE_ID
The service SERVICE_ID is no longer available.
added
A new service is available.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The id of the new service. |
provider |
object | A reference to the service provider object. |
added∙SERVICE_ID
A new service called SERVICE_ID is available.
Parameters:
Name | Type | Description |
---|---|---|
provider |
object | A reference to the service provider object. |
removed
A service is no longer available.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The id of the service. |
removed∙SERVICE_ID
The service SERVICE_ID is no longer available.