Skip to content

docs: add TS examples for CloudEvent usage #461

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

Merged
merged 2 commits into from
Jan 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,29 @@ const ce = new CloudEvent({...});
const ce2 = ce.cloneWith({extension: "Value"});
```

You can create a `CloudEvent` object in many ways, for example, in TypeScript:

```js
import { CloudEvent, CloudEventV1, CloudEventV1Attributes } from "cloudevents";
const ce: CloudEventV1<string> = {
specversion: '1.0',
source: '/some/source',
type: 'example',
id: '1234'
};
const event = new CloudEvent(ce);
const ce2: CloudEventV1Attributes<string> = {
specversion: '1.0',
source: '/some/source',
type: 'example',
};
const event2 = new CloudEvent(ce2);
const event3 = new CloudEvent({
source: '/some/source',
type: 'example',
});
```

### Example Applications

There are a few trivial example applications in
Expand Down