Documentation

Mistake on this page? Email us

Resource

Hierarchy

  • EventEmitter
    • Resource

Index

Constructors

constructor

Events

EVENT_NOTIFICATION

EVENT_NOTIFICATION: string = "notification"

Resource notification event which returns the notification when handling notifications, otherwise an asyncId

Properties

contentType

contentType: string

The content type of the resource

deviceId

deviceId: string

Related device ID

obs

obs: boolean

Observable determines whether you can subscribe to changes for this resource. It can have values "true" or "false".

observable

observable: boolean

Whether you can subscribe to changes for this resource

path

path: string

Resource's URL

rt

rt: string

Application specific resource type that describes this resource. It is created by the client side application. Not meant to be a human-readable name for the resource. Multiple resource types may be included, they are separated by a space.

type

type: string

The content type of the resource.

Important
You are encouraged to use the resource types listed in the LwM2M specification. Resource's type

uri

uri: string

The URL of the resource.

defaultMaxListeners

defaultMaxListeners: number

Methods

addListener

  • addListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

execute

  • execute(payload?: any, timeout?: number, mimeType?: string, accepts?: string): Promise<AsyncResponse>
  • Execute a function on a resource

    Note: This method requires a notification channel to be set up

    Parameters

    • Optional payload: any

      The payload to be sent to the device.

    • Optional timeout: number

      async request will timeout after given number of milliseconds

    • Optional mimeType: string

      The content type of the payload

    • Optional accepts: string

      The content type of an accepted response

    Returns Promise<AsyncResponse>

    the AsyncResponse

  • execute(payload?: any, timeout?: number, mimeType?: string, accepts?: string, callback?: CallbackFn<AsyncResponse>): void
  • Execute a function on a resource

    Note: This method requires a notification channel to be set up

    Parameters

    • Optional payload: any

      The payload to be sent to the device.

    • Optional timeout: number

      async request will timeout after given number of milliseconds

    • Optional mimeType: string

      The content type of the payload

    • Optional accepts: string

      The content type of an accepted response

    • Optional callback: CallbackFn<AsyncResponse>

      A function that is passed any error

    Returns void

getMaxListeners

  • getMaxListeners(): number
  • Returns number

getSubscription

  • getSubscription(): Promise<boolean>
  • Gets the status of a resource's subscription

    Returns Promise<boolean>

    Promise containing resource subscription status

  • getSubscription(callback: CallbackFn<boolean>): void
  • Gets the status of a resource's subscription

    Parameters

    • callback: CallbackFn<boolean>

      A function that is passed (error, subscribed) where subscribed is true or false

    Returns void

getValue

  • getValue(timeout?: number, mimeType?: string): Promise<string | number | void>
  • Gets the value of a resource

    Note: This method requires a notification channel to be set up

    Parameters

    • Optional timeout: number

      async request will timeout after given number of milliseconds

    • Optional mimeType: string

      The requested mime type format of the value

    Returns Promise<string | number | void>

    Promise of resource value

  • getValue(timeout?: number, mimeType?: string, callback?: CallbackFn<string | number | void>): void
  • Gets the value of a resource

    Note: This method requires a notification channel to be set up

    Parameters

    • Optional timeout: number

      async request will timeout after given number of milliseconds

    • Optional mimeType: string

      The requested mime type format of the value

    • Optional callback: CallbackFn<string | number | void>

      A function that is passed the arguments (error, value) where value is the resource value

    Returns void

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

setValue

  • setValue(value: string, timeout?: number, mimeType?: string): Promise<AsyncResponse>
  • Sets the value of a resource

    Note: This method requires a notification channel to be set up

    Parameters

    • value: string

      The value of the resource

    • Optional timeout: number

      async request will timeout after given number of milliseconds

    • Optional mimeType: string

      The mime type format of the value

    Returns Promise<AsyncResponse>

    the AsyncResponse

  • Sets the value of a resource

    Note: This method requires a notification channel to be set up

    Parameters

    • value: string

      The value of the resource

    • Optional timeout: number

      async request will timeout after given number of milliseconds

    • Optional mimeType: string

      The mime type format of the value

    • Optional callback: CallbackFn<AsyncResponse>

      A function that is passed any error

    Returns void

listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number