diff --git a/index.html b/index.html index 8c2934f6..fdf57d5d 100644 --- a/index.html +++ b/index.html @@ -2397,8 +2397,6 @@

The ExposedThing interface

EventSubscriptionHandler handler); ExposedThing setEventUnsubscribeHandler(DOMString name, EventSubscriptionHandler handler); - ExposedThing setEventHandler(DOMString name, - EventListenerHandler eventHandler); Promise<undefined> emitEvent(DOMString name, InteractionInput data); @@ -2422,7 +2420,6 @@

The ExposedThing interface

callback EventSubscriptionHandler = Promise<undefined>( optional InteractionOptions options = null); - callback EventListenerHandler = Promise<InteractionInput>();
@@ -3124,21 +3121,6 @@

The ActionHandler callback

-
-

The EventListenerHandler callback

-

- A function that is called when an associated Event is triggered - and provides the data to be sent with the Event to subscribers. - Returns a {{Promise}} that resolves with {{InteractionInput}} value - that represents the Event data, or rejects with an error. -

-

- Applications MAY return {{ReadableStream}} from an {{EventListenerHandler}} - Implementations will then use the stream provided in - {{InteractionOutput}} when constructing the event notification. -

-
-

The EventSubscriptionHandler callback

@@ -3321,52 +3303,10 @@

The EventSubscriptionHandler callback

-

The setEventHandler() method

-

- Takes as arguments |name:string| and |eventHandler:EventListenerHandler|. - Sets the event handler function for the specified Event - matched by |name|. - Throws on error. - Returns a reference to |this| object for supporting chaining. -

-

- The |eventHandler| callback function will implement what to do when the - event is emitted. It SHOULD resolve with a value that represents the - Event data, or reject with an error. -

-

- There MUST be at most one handler for any given Event, so newly added handlers MUST replace the previous handlers. -

-
- When the method is invoked with |name:string| and - |eventHandler:EventListenerHandler|, run the following steps: -
    -
  1. - If invoking this method is not allowed for the current scripting context for security reasons, [= exception/throw =] a {{SecurityError}} and abort these steps. -
  2. -
  3. - Let |interaction| be the value of [[\td]]'s |events|'s - |name|. -
  4. -
  5. - If an Event with the name |name| is not found, - [= exception/throw =] a {{NotFoundError}} and abort these steps. -
  6. -
  7. - Set the internal slot [[\eventHandler]] of |interaction| to - |eventHandler|. -
  8. -
  9. - Return `this`. -
  10. -
-
-
-

Handling Events

When an Event with name |name| is emitted with - |data:InteractionInput| either by the underlying platform or by the + |data:InteractionInput| by the emitEvent() method, run the following steps:
    @@ -3374,22 +3314,6 @@

    The EventSubscriptionHandler callback

    Let |interaction| be the value of [[\td]]'s |events|'s |name|. -
  1. - If |data| is not defined or `null`, -
      -
    1. - Let |eventHandler| be the value of the [[\eventHandler]] - internal slot of |interaction|. -
    2. -
    3. - If |eventHandler| is failure, abort these steps. -
    4. -
    5. - Let |data| be the result of awaiting to resolve the invocation - of |eventHandler|. If it rejects, abort these steps. -
    6. -
    -
  2. For each |subscriber| in the internal listener list of |interaction|, run the following sub-steps: @@ -3398,6 +3322,12 @@

    The EventSubscriptionHandler callback

    Create an Event notification |response| according to the Protocol Bindings from |data| and |subscriber|, including its |options|. +
  3. +
  4. + If |data| is `undefined`, assume that the notification |response| + will contain an empty data payload as specified by Protocol Bindings. +
  5. +
  6. If the underlying protocol stack permits conveying event errors and if an error condition has been detected by the UA, create |response| as an error notification according to the Protocol Bindings, @@ -3439,11 +3369,8 @@

    The EventSubscriptionHandler callback

  7. Make a request to the underlying platform to emit an Event - with |data|. -

    - This will trigger the handling events - steps. -

    + with |data|. Call the handling events + steps.
diff --git a/typescript/scripting-api/index.d.ts b/typescript/scripting-api/index.d.ts index b699880d..e716d419 100644 --- a/typescript/scripting-api/index.d.ts +++ b/typescript/scripting-api/index.d.ts @@ -276,14 +276,6 @@ declare namespace WoT { */ setEventUnsubscribeHandler(name: string, handler: EventSubscriptionHandler): ExposedThing; - /** - * Takes as arguments name and eventHandler. - * Sets the event handler function for the specified Event matched by name. - * Throws on error. - * Returns a reference to the same object for supporting chaining. - */ - setEventHandler(name: string, handler: EventListenerHandler): ExposedThing; - /** * Takes as arguments name denoting an Event name and data. * Triggers emitting the Event with the given data. @@ -304,8 +296,6 @@ declare namespace WoT { export type EventSubscriptionHandler = (options?: InteractionOptions) => Promise; - export type EventListenerHandler = () => Promise; - } declare module "wot-typescript-definitions" {