Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dreamworld/device-info

Package Overview
Dependencies
Maintainers
4
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dreamworld/device-info

It's used to get basic details of device(layout, touch and virtual keyboard).

  • 1.0.0-init.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
51
Maintainers
4
Weekly downloads
 
Created
Source

DeviceInfo

It's used to get detail about Device like:

  • Screen Size: small, medium, large, hd and fullhd
  • Pointer Interface: Mouse vs Touch
  • Keyboard Interface: Virtual vs Physical

Many UI components need to adjust their look & feel and/or behaviours based on this detail. They can use this to get this information; and get updated when any of this information is changed.

All of the @dreamworld/* Web Components uses (are going to use) this.

Usage pattern

  • We can use this controller with 2 methods
import DeviceInfo from "@dreamworld/device-info";

//Get info
let deviceInfo = DeviceInfo.info(); // { layout: "small", touch: true, vkb: false }

Use it Globally (Plain JS)

import DeviceInfo from "@dreamworld/device-info";

//Bind event
DeviceInfo.on("change", (details) => {
  //details contains only properties which are really changed.
});

//Unbind event
DeviceInfo.off("change", handler);

Use it as Lit Reactive Controller

import { LitElement, html } from "lit";
import DeviceInfo from "@dreamworld/device-info";

class MyComponent extends LitElement {
  deviceInfo = new DeviceInfo(this);

  // Use the controller in render()
  render() {
    return html`
      current layout: ${this.deviceInfo.layout} is touch enabled: ${this
        .deviceInfo.touch} is Virtual keyboard supported: ${this.deviceInfo.vkb}
    `;
  }
}

Enable redux

import { default as DeviceInfo, selectors } from "@dreamworld/device-info";

//Init redux
DeviceInfo.initRedux(store);

//use selectors to read details from redux store

let layout = selectors.layout(state);
let isTouchEnabled = selectors.touch(state);
let isVKBEnabled = selectors.vkb(state);

It manages state at below path.

Path: device-info

namedata typedescription
layoutStringPossible values: small, medium, large, hd and fullhd.
touchBooleantrue if device touch is enabled. false otherwise.
vkbBooleantrue if device virtual keyboard is supported. false otherwise.

FAQs

Package last updated on 23 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc