1.0.5 • Published 4 years ago

layers-portal-sdk v1.0.5

Weekly downloads
8
License
GPL-3.0-or-later
Repository
github
Last release
4 years ago

Layers Portal SDK for JavaScript v1

npm NPM

<script>
window.LayersPortalOptions = {
  appId: "test-app"
}
!function(){var e;window.LayersPortal||(window.LayersPortal=((e=function(t,r){return new Promise((function(n,a){e.q.push([n,a,t,r])}))}).q=[],e.eh={},e.on=function(t,r){var n=e.eh[t]||[];n.push(r),e.eh[t]=n},e.ready=!1,e.connected=!1,e.platform=null,e));var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://js.layers.digital/v1/LayersPortal.js";var r=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(t,r)}();
</script>

Example:

LayersPortal.on('ready', function () {
  // Called when SDK is ready
})

LayersPortal.on('connected', function (data) {
  /**
  data = {
    session: ...
    userId: ...
    communityId: ...
    accountId: ...
  }
  */

  // Called when SDK connects with Layers
})

/* Closing window */
const promise = LayersPortal('close')

/* Using async/await */
try {
  const result = await promise
  // Use result
} catch (error) {
  // Handle errors
}

/* Using then/catch */
promise.then(result => {
  // Use result
}).catch(error => {
  // Handle errors
})
1.0.5

4 years ago

1.0.4

5 years ago

1.0.0

5 years ago