Reactive XComponent API
Reactive XComponent is a javaScript client API that allows you to interact with microservices generated with XComponent software.
Install
install the latest version of the API:
npm :
npm i reactivexcomponent.js --save
yarn :
yarn add reactivexcomponent.js
Usage
Import in JS :
;
Import in TS :
;const xcomponent = ;
Set/Get LogLevel of the API :
; xcomponent;const logLevel = xcomponent;
Connect to XComponent WebSocket Bridge :
const serverUrl = 'ws://localhost:443'; xcomponent;
Get the list of available APIs on the WebSocket Bridge :
connection;
Create a Session on a specific API :
const xcApiName = "HelloWorldApi.xcApi" connection;
Variables used in the following examples :
const componentName = "HelloWorld";const stateMachineName = "HelloWorldManager";const stateMachineResponse = "HelloWorldResponse"; const jsonMessage = "Name": "Test" ;const messageType = "XComponent.HelloWorld.UserObject.SayHello";
Get the Snapshot using a Session :
session;
Get StateMachine updates through an Observable using a Session :
const updates$ = session;
Send a message to all instances of a state machine using a Session :
// You can use the method canSend to check if the session is alowed the send this event to this state machine.if session session;
Send a message to a specific state machine instance using a StateMachineInstance or StateMachineRef :
stateMachineInstance;
Build from source
Download the source code and execute the following commands:
yarn install
yarn build
xcomponentapi.js is built in the lib folder.
Run unit tests
Execute the following command:
yarn test
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request
License
Apache License V2