Documentation about backward compatibility
This commit is contained in:
parent
ad3902efaf
commit
f58b8baa3b
22
README.md
22
README.md
|
|
@ -51,6 +51,20 @@ Javascript SDK for CloudEvents
|
||||||
*/
|
*/
|
||||||
var cloudevent01 = new Cloudevent();
|
var cloudevent01 = new Cloudevent();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implemented using [Builder Design Pattern](https://en.wikipedia.org/wiki/Builder_pattern)
|
||||||
|
*/
|
||||||
|
cloudevent01
|
||||||
|
.type("com.github.pull.create")
|
||||||
|
.source("urn:event:from:myapi/resourse/123");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Backward compatibility by injecting methods from spec implementation to `Cloudevent`
|
||||||
|
* See how [here](lib/specs/spec_0_1.js#L17)
|
||||||
|
*/
|
||||||
|
cloudevent01
|
||||||
|
.eventTypeVersion("1.0");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructs an instance with:
|
* Constructs an instance with:
|
||||||
* - Spec 0.2
|
* - Spec 0.2
|
||||||
|
|
@ -58,4 +72,12 @@ var cloudevent01 = new Cloudevent();
|
||||||
*/
|
*/
|
||||||
var cloudevent02 = new Cloudevent(Cloudevent.specs['0.2']);
|
var cloudevent02 = new Cloudevent(Cloudevent.specs['0.2']);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Different specs, but the same API.
|
||||||
|
*/
|
||||||
|
cloudevent02
|
||||||
|
.type("com.github.pull.create")
|
||||||
|
.source("urn:event:from:myapi/resourse/123");
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,13 @@ describe("CloudEvents Spec 0.1 - JavaScript SDK", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Backward compatibility", () => {
|
||||||
|
it("should have 'eventTypeVersion'", () => {
|
||||||
|
cloudevent.eventTypeVersion("1.0");
|
||||||
|
expect(cloudevent.format()).to.have.property('eventTypeVersion');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue