1.1.1 • Published 2 years ago

frontline-client v1.1.1

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Frontline Javascript Client

This library is used to interact with the Frontline WebSocket API.

An example usage is below.

import {Client} from './index.js';

const url = location.origin;

function save_session(data) {
  localStorage.setItem("session", JSON.stringify(data));
}

function maybe_session() {
  let s = localStorage.getItem("session");
  s = JSON.parse(s);
  return s;
}

function init(session) {
  save_session(session)
  fl.init(session)
}

let session = maybe_session();

function open(event){
  console.info("Open:", event.detail);
}

function initialized(event){
  console.log("channel initialized:", event.detail);
}

function updated(event){
  console.log("channel updated:", event.detail);
}

window.fl = new Client(url);
window.fl.addEventListener("open", open);
window.fl.addEventListener("initialized", initialized);
window.fl.addEventListener("updated", updated);

if(!session){
  let email = prompt("Email Address");
  fl.send_login_email(email);
  let token = prompt("Login Token");
  fl.authenticate(token)
    .then(session => init(session));
}else{
  init(session);
}
1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.0

2 years ago