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

@scrbbl/scribblelive-toolkit-core

v1.1.4

Published

This package allows developers to easily integrate with Scribblelive streams.

Downloads

16

Readme

Scribblelive Toolkit Core

This package allows developers to easily integrate with Scribblelive streams.

Installation

To install the package run npm i @scrbbl/scribblelive-toolkit-core

If you would like a compiled ES5 version of the library, you can include the SLToolkit.js file located under ./lib folder in your web project

Prerequisites

  • Scribblelive authentication token

Load Stream Example

This example assumes the use of npm and a module bundler such as webpack.

const SLToolkit = require('@scrbbl/scribblelive-toolkit-core');

const token = 'my-token';
const streamId = 123456;
const options = {};

/* by default, we collect metrics to then display stats about how much your audience engaged with your content
   you can disable this tracking via the following

    options.tracking = false;

 // or keep it enabled but specify a custom source type  ex:
 
    options.tracking = { source: 'native-ios' };

 // to specify custom log level: 

    options.logging = { logLevel: 4 };
*/



// initialize the core module
const Core = new SLToolkit({token, options});

// load stream content
Core.Stream.load(streamId, (err, data) => {
  // load function takes a callback function

  if (err){
    // handle error
    return;
  }

  console.log('Loaded Stream: ', data);
});

// start polling
Core.Stream.poll(streamId, (err, data) => {
  if (err){
    // handle error
    return;
  }

  console.log('Polling Stream: ', data);
});

// get 10th page
Core.Stream.page(streamId, options.paging.pageSize, 10, (err, data) => {
  if (err){
    // handle error
    return;
  }
  
  console.log('Paging Stream: ', data);
});

// stops all polling
setTimeout(function() {
  Core.Stream.killAllPolls();
}, 20000);

Loading Stream Example (non-npm)

index.html

<html>
  <head></head>
  <body>
    <!-- order is important, the core must be loaded first -->
    <script src="SLToolkit.js"></script>
    <script src="my-app.js"></script>
    </body>
</html>

my-app.js

var token = 'my-token';
var streamId = 123456;
const options = {};

// initialize the core module
var Core = new SLToolkit({ token, options });

// load stream content
Core.Stream.load(streamId, function (err, data) {
  // load function takes a callback function

  if (err) {
    // handle error
    console.log(err);
    return;
  }

  console.log(data);
});

// start polling
Core.Stream.poll(streamId, (err, data) => {
   if (err) {
       // handle error
        console.log(err);
        return;
    }
    // render data into DOM
    console.log(data);
});

// stops all polling
setTimeout(function() {
    Core.Stream.killAllPolls();
}, 10000);

Stream Methods

Promise load(int streamId, callback)

Loads the first page of the specified stream ID. The callback function is invoked after the data has been loaded successfully. A promise is returned when load is invoked. The Promise can be used instead of the callback function.

Promise page(int streamId, int pageSize, int pageNumber, callback)

Loads the pageSize'th page of the pageSize for the specified stream ID. The callback function is invoked after the data has been loaded successfully. A promise is returned when load is invoked. The Promise can be used instead of the callback function.

int poll(int streamId, callback)

Polls the server for updates to the specified stream. If updates are present, the callback function will be invoked. The poll ID is returned when poll is called.

boolean killPoll(int pollId)

Terminates polling for the specified poll ID (returned from calling the poll function). If successful, the function will return true.

boolean killAllPolls()

Terminates all polls that have been initiated. The function will return a boolean to indicate if it was successful.

Array getAllPolls()

Returns a list of all the poll IDs that are currently registered in the Toolkit.

Modules

Modules are packages that can be added to a project and used through the Core. This allows for a single object to be created that will hold all functionality.

To install a module you simply have to install it using npm within the project that the Core already resides: Example for the Likes Module: npm i @scrbbl/scribblelive-toolkit-likes

| Module | Purpose | | ------ | ------- | | Poll Post Types | This module gives full functionality to the poll post types, allowing users to vote on options and have them automatically update independant of the Stream | | Collections | This module allows for easy functionality with the collections-api through the Core | | Likes | This module gives functinoality for liking posts using the Core |

Made with :heart: at ScribbleLive