File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,11 @@ Every Spec class must implement these methods to work properly.
94
94
95
95
``` js
96
96
97
+ /*
98
+ * The constructor must receives the Cloudevent type.
99
+ */
100
+ Spec (Cloudevent)
101
+
97
102
/*
98
103
* Check the spec constraints, throwing an error if do not pass.
99
104
*/
@@ -168,6 +173,35 @@ var formatted = cloudevent.format();
168
173
169
174
```
170
175
176
+ ## Hot to emit the event?
177
+
178
+ ``` js
179
+ // The event
180
+ var cloudevent = new Cloudevent ()
181
+ .type (" com.github.pull.create" )
182
+ .source (" urn:event:from:myapi/resourse/123" );
183
+
184
+ // The binding configuration using POST
185
+ var config = {
186
+ method: ' POST' ,
187
+ url : ' https://mywebhook.com'
188
+ };
189
+
190
+ // The binding instance
191
+ var binding = Cloudevent .bindings [' http-structured0.1' ](config);
192
+
193
+ // Emit the event using Promise
194
+ binding .emit (cloudevent)
195
+ .then (response => {
196
+ // Treat the response
197
+ console .log (response .data );
198
+
199
+ }).catch (err => {
200
+ // Treat the error
201
+ console .error (err);
202
+ });
203
+ ```
204
+
171
205
> See how to implement the method injection [ here] ( lib/specs/spec_0_1.js#L17 )
172
206
>
173
207
> Learn about [ Builder Design Pattern] ( https://en.wikipedia.org/wiki/Builder_pattern )
You can’t perform that action at this time.
0 commit comments