-
Notifications
You must be signed in to change notification settings - Fork 69
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
Should a cloneWith update the id and time fields? #361
Comments
@lholmquist good question. It might be worth asking in CloudEvents slack channel. My gut is to say that these values should not be cloned - especially the ID. |
Not to many responses from the slack channel, other then me and you @lance thinking that those values should be updated wit ha cloneWith and @grant suggesting that we don't have this method, and just let users create a new Cloudevent themselves, which gets around the issue. Grants suggestion: sdk-javascript/src/event/cloudevent.ts Line 187 in 1446898
We could probably remove the cloneWith, but it would have to be in a major version. i don't remember if there was a reason why we opted for hte clonewith and not just use the contructor again? |
I suggest not having this method imo. Keeping the interface as small as possible is really ideal in the long term. I deal with similar issues across consistency between implementations across 7 implementations with a similar library. |
I'm fine with removing the method in 4.0.0 because it's correct that the user can do this themselves. Though frankly, I think it would be better to just deprecate it initially. But there is one thing I think we should consider changing before that. Even though we eliminated munging the sdk-javascript/src/event/cloudevent.ts Lines 125 to 134 in 8205bc9
The side effect of this is that simply using an event as the parameter to the constructor doesn't work. You end up losing the
Note that no It's because of this that the implementation of Anyway, this is all a long way of saying I think we should set the |
It looks like we can break this into a couple workable issues.
as for if a user modifies the data, put a warning on the readme when we introduce the change? |
This issue is stale because it has been open 30 days with no activity. |
I was playing with an example on using the
cloneWith
method of the CloudEvent class and i noticed that the new returned(cloned) CloudEvent has the sameid
andtime
values.So for example:
And then if we wanted to add an extension, for instance, we could clone it into a new cloud event
I wasn't sure if that is correct or not. I can go either way on this. On one hand, it is just a clone with added features, but on the other hand, we are creating a brand new CloudEvent, so should the id and time be recreated?
The text was updated successfully, but these errors were encountered: