npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

btca-client

v2.0.4

Published

Client for interacting with Bigtincan Hub JavaScript Bridge 3.0

Downloads

1,692

Readme

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.

import BTCAClient from 'btca-client';

import 'btca-client/css/btca.css';

You can also use the standalone UMD build via CDN.

<script src="https://unpkg.com/btca-client/lib/btca.min.js"></script>

<link href="https://unpkg.com/btca-client/css/btca.min.css" rel="stylesheet">

Usage

Initialise a new instance of the BTCAClient.

var BTCA = new BTCAClient({
  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 action
var data = {
  action: 'getEntity',
  params: {
    entityName: 'story',
    id: 123
  }
};

// send with anonymous callback
BTCA.send(data, function(result, requestId, error) {
  console.log(result);
});

// send with callback reference
BTCA.send(data, handleRequestResponse);

// send with btcjsapi:// schema and named jsListener callback
BTCA.send('btcjsapi://getList?entityName=story&id=123&jsListener=handleRequestResponse')

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 a sendMail action.
  • Anchor tags with an absolute URL or rel=app are treated as Hub links and will send an openURL action.
  • Anchor tags with an http(s) link or rel=external are treated as external links and will send an openURL action.
  • Anchor tags with btcjsapi:// will send the specified action.