Skip to content
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

things as simple objects #4

Open
draggett opened this issue Nov 4, 2018 · 1 comment
Open

things as simple objects #4

draggett opened this issue Nov 4, 2018 · 1 comment
Labels
enhancement New feature or request

Comments

@draggett
Copy link
Owner

draggett commented Nov 4, 2018

The aim is to simplify the API used by client developers still further by using getters and setters for synchronous updates to object properties, and by treating actions as object methods that return promises. The client platform should validate data and thrown an exception if the app tries to pass a value that is invalid in respect to the thing description. Asynchronous errors are reported via events, e.g. loss of connection or an error reported by the server, but note that actions are asynchronous and the app should deal with errors through the promise returned when invoking an action. We need to agree on a means to separate the system events from the events declared in thing descriptions. One idea is by event name, but another idea would be to an API for subscribing to system events, e.g. to set onerror handlers. The error pattern is common place for node and for the browser DOM.

@draggett draggett added the enhancement New feature or request label Nov 4, 2018
@draggett
Copy link
Owner Author

draggett commented Nov 4, 2018

One complication is how to get the model given a thing. One idea is to reserve part of the name space for object properties, e.g. all properties whose name starts with "@", this thing["@model"] would provide the model for the thing. My plan is to layer all this on top of the platform abstraction API, e.g. a setter for a thing's property would first validate value against the thing description, then call the thing's platform's write method which returns a promise. If the promise is rejected, this would be used to notify a system event.

How many events need to be defined?

  • errors for property read and write - in most cases, client-side data validation should avoid these errors
  • unexpected loss of connectivity and restoration of connectivity
  • invalid bearer token, e.g. where a previously valid token has expired or been revoked
  • updates to metadata and to the declarations for properties, actions and events

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

No branches or pull requests

1 participant