Skip to content

setPropertyWriteHandler() gives impression that all properties will be writeable #199

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
egekorkan opened this issue Nov 18, 2019 · 3 comments

Comments

@egekorkan
Copy link
Contributor

In the explanation of setPropertyWriteHandler(), it says:

If no write handler is initialized for any given Property, implementations SHOULD implement default property update and notifying observers on change, based on the Thing Description.

I think that it should be rather:

If no write handler is initialized for any given writeable (or non readOnly) Property, implementations SHOULD implement default property update and notifying observers on change, based on the Thing Description.

Otherwise, it gives the impression that a Scripting API implementer should add a write handler for properties that are readOnly as well.

@zolkis
Copy link
Contributor

zolkis commented Jan 13, 2020

Note that a write handler will have access to low level HW APIs, so it is supposed to define the write behavior at its own will, including what errors to return. If implementations trust the app to provide write handler for positive use cases, I don't see why they should not trust apps for providing implementation for negative use cases as well.

In my view, even for readonly Properties, any ExposedThing script (app) implementation could specify a write handler.
If it does not, then a default handler is assigned by the implementation.
If it is defined, it is supposed to define the behavior of how write is rejected and should be executed by the implementation.

@egekorkan
Copy link
Contributor Author

If it does not, then a default handler is assigned by the implementation.

I totally agree with this, but the current explanation gives the impression that the default handler will update the property and then also notify the observers about the change, even if it is not writeable.
This means that if I write a script where I want a property to be readOnly for sure, there can be a Scripting API implementation that still does an update.

@zolkis
Copy link
Contributor

zolkis commented Jan 13, 2020

OK, so we should explain the exact behavior in more details.

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

2 participants