-
Notifications
You must be signed in to change notification settings - Fork 19
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for schema-based message definitions #846
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @shakyShane and the rest of your teammates on Graphite |
cf001bb
to
92e2387
Compare
What's changed in the update:
|
@jonathanKingston I need to add a couple of unit tests for the code-gen part, but this is ready to re-review now :) |
CC: @muodov |
8959f04
to
99df884
Compare
21defdb
to
25e0670
Compare
@jonathanKingston I updated the description with the new simpler model. |
@jonathanKingston can you take another look through this 馃檹馃徎 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting this over the line! Really great work!
Feature entry pointbeforeFeatures can opt-in when ready. Each feature would contain 3 top-level keys
notifications
requests
subscriptions
These are designed to match the messaging API directly, and will provide automatic documentation for
native teams as they integrate.
Feature entry point NEW
Place a folder inside
src/messages
with at least 1 notification, request or subscriptionWhen you have multiple messages, will look more like
src/messages
Individual MessageThe important parts of a message are:
method
this is what native teams will map to their handlersparams
(optional) this is the payload we'll send in the outgoing messageresult
(optional) this is the payload the native side will return in a response to a request.Individual Message NEW
Notifications
Notifications have 2 elements -
method
andparams
.method
: this is represented in the filename, everything before the first.
will be usedparams
: in your json schema file, add the object type and properties as seen belownotification without params
Given the filename
debug.notity.json
, this will generatenotification with params
Given the filename
debug.notity.json
, this will generaterequests & responses
Requests work the same, except they use the file format
debug.request.json
.Requests differ from Notifications in that they have an optional return type.
To create a return type, create a new file
debug.response.json
.As above, the response can contain an object with properties.
For example, it might be common to not have any params, but to expect a return types (for example, when fetching data).
To create that situation, create the following 2 file
fetchData.request.json
fetchData.response.json
These 2 files would create the following:
subscriptions
Subscriptions use the file format
onChange.subscribe.json
.onChange
from the filenameGenerated Types
From those JSON files, we get these types that can be imported and used in each feature
Javascript Usage
Once we have the types, we can proxy calls to
notify
,request
andsubscribe
and providetype-checking.
For example, from the types above we know that this feature can only make a
request
forwebShare
.