btca-client
BTCA Client library. See JavaScript Bridge 3.0 documentation for available actions.
Installation
npm install btca-client --save
You can now import btca-client
and optionally include a CSS reset.
; ;
You can also use the standalone UMD build via CDN.
Usage
Initialise a new instance of the BTCAClient.
var BTCA = handle: 'MY_BTCA' // unqiue handle to identify BTCA cache: false // caches requests (useful for debugging) disableEvents: false // disables default events (see below) log: false // logs actions to console;
Send Request
There are various ways to perform a JSBridge request.
// define your JSBridge actionvar data = action: 'getEntity' params: entityName: 'story' id: 123 ; // send with anonymous callbackBTCA; // send with callback referenceBTCA; // send with btcjsapi:// schema and named jsListener callbackBTCA
Disabling Default Events
By default, JSBridge actions are bound to various anchor click events. If you'd like to disable this and handle it yourself you may set disableEvents: true
when initialising.
- Anchor tags with
mailto:
are parsed and will send asendMail
action. - Anchor tags with an absolute URL or
rel=app
are treated as Hub links and will send anopenURL
action. - Anchor tags with an http(s) link or
rel=external
are treated as external links and will send anopenURL
action. - Anchor tags with
btcjsapi://
will send the specified action.