8000 Should a cloneWith update the id and time fields? · Issue #361 · cloudevents/sdk-javascript · GitHub
[go: up one dir, main page]

Skip to content
Should a cloneWith update the id and time fields? #361
Open
@lholmquist

Description

@lholmquist

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 same id and time values.

So for example:

const ce = new CloudEvent({....});

ce.toJSON();   

// might be something like this:
{
  id: 12345,
  time: '1:00 pm' // i know that is not the format
}

And then if we wanted to add an extension, for instance, we could clone it into a new cloud event

const ce2 = ce.cloneWith({extenstion: 'Vaule'});

c2.toJSON()

// might be something like this:
{
  id: 12345,
  time: '1:00 pm',
  extension: 'Value'
}

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0