-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
Expose changeset content #287
Expose changeset content #287
Conversation
We could also rename it to |
Awesome, thanks for taking the time @makepanic. I'll review this after work today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just some minor comments.
README.md
Outdated
|
||
```js | ||
let user = { name: 'Bobby', age: 21, address: { zipCode: '10001' } }; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add let changeset = new Changeset(user);
?
addon/index.js
Outdated
@@ -177,6 +181,7 @@ export function changeset( | |||
errors: objectToArray(ERRORS, (e /*: Err */) => ({ value: e.value, validation: e.validation }), true), | |||
change: inflate(CHANGES, c => c.value), | |||
error: inflate(ERRORS, e => ({ value: e.value, validation: e.validation })), | |||
content: reads(CONTENT).readOnly(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be readOnly(CONTENT)
, without the reads
?
tests/unit/changeset-test.js
Outdated
|
||
assert.throws(() => set(dummyChangeset, 'content', { foo: 'bar' }), ({message}) => { | ||
return message === "Cannot set read-only property 'content' on object: changeset:[object Object]"; | ||
}, 'should throw error'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.throws(
() => set(dummyChangeset, 'content', { foo: 'bar' }),
({ message }) => message === "Cannot set read-only property 'content' on object: changeset:[object Object]",
'should throw error'
);
Would like to see the args on separate lines just for clarity. :)
4c8dcdb
to
adaa0b2
Compare
I've made the requested changes and renamed the attribute to |
@makepanic Wrote up some release notes and published the latest on npm, thanks for the PR dude! Lemme know if there are any problems. |
I don't believe this |
Changes proposed in this pull request
This PR adds a new readonly getter that returns the object that was wrapped in the changeset.
The change can potentially close #139 as it exposes a way to access
_content
.I'm unsure if
content
is a good name as it potentially conflicts with the proxied objectscontent
attribute.