Skip to content

Do we need an EventHandler? #408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
relu91 opened this issue Jun 13, 2022 · 8 comments
Closed

Do we need an EventHandler? #408

relu91 opened this issue Jun 13, 2022 · 8 comments
Assignees

Comments

@relu91
Copy link
Member

relu91 commented Jun 13, 2022

In the Handling Events flow, we are stating that if data is null or undefined the runtime should ask the internal slot eventHandler to return something for sending it to the network.

However, I don't think we have such a use case: a caller does not know what to send for a particular event and defers the decision to the backend logic of an ExposedThing.

This choice makes also it quite inconvenient to cover the use case described in #402. In other words, if an event has not data here's the code needed to implement it:

var produced; // Produced Thing
produced.setEventHandler("noDataEvent", () => undefined);
// exposing
await produced.expose();
produced.emitEvent("noDataEvent");

Whereas if we just rely on the data passed on the emitEvent method we could simply:

var exposed;
exposed.emitEvent("noDataEvent");
@danielpeintner
Copy link
Contributor

Call 2022-07-04

  • recall use-case from TUM having this handler, @danielpeintner will look it up

@egekorkan
Copy link
Contributor

I am not 100% sure but this was about implementing a shadow thing or a proxy. I am proxying a local thing to the public network and before having this event handler, the proxy would subscribe to all events even if there is no consumer of the proxy interested in some of the events. With the event handler, when a subscription request comes to the proxy, it will subscribe in the event handler.

However, I think I am not seeing something since in my point of view, there is no difference in an event having data or not.

@danielpeintner
Copy link
Contributor

The issue @egekorkan is mentioning is #211.

I "think" the issue is the same for events and observing property changes...

@danielpeintner
Copy link
Contributor

Call 2022-07-11
Maybe @egekorkan has a "picture/diagram" to show the problem... network configuration/setup. We were not 100% sure.
@egekorkan would you have time to join a call once?

@egekorkan
Copy link
Contributor

I can join next week. I think that I have confused it with eventsubscription handler

@danielpeintner
Copy link
Contributor

Call 2022-07-18

  • agreed that there is no need for EventHandler
  • check whether we can merge Section 9.28 and 9.29
  • @relu91 will work on PR

@zolkis
Copy link
Contributor

zolkis commented Aug 8, 2022

agreed that there is no need for EventHandler

Let's record the justification in more detail, please. I wonder if we all mean the same things and use cases about this EventHandler.

  • The context is ExposedThing, but specifying a customized (hooked) ConsumedThing side (how to handle events, for instance in case of Thing proxy implementations)
  • In contrast, emitEvent() is the ExposedThing side
  • Constructing an ExposedThing starts with a TD that defines event names
  • The code for ExposedThing defines the behavior by adding functions that interact with the underlying platform and implement the interfaces of event handling,
  • then register them as handlers for various interactions

So far the handler for handling events in ExposedThing has been defined by a user-defined function.

So are we now saying that:

  • there is no need for user-defined event handler functions in ExposedThing, i.e. no hooks are possible and the WoT Scripting API implementations must implement and use a default event handling?
  • if so, what is the algorithm for event handling, is it standardized, or is it left to the implementations?

I'd say if there are no strong use cases for the EventHandler hook on ExposedThing, we should indeed remove it, to simplify the spec.

@danielpeintner
Copy link
Contributor

Call 2022-08-08

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants