Skip to content
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

Add m.prop #2268

Merged
merged 1 commit into from
Nov 7, 2018
Merged

Add m.prop #2268

merged 1 commit into from
Nov 7, 2018

Conversation

dead-claudia
Copy link
Member

@dead-claudia dead-claudia commented Oct 29, 2018

Description

Exactly what it says on the tin, but I added the .get/.set version proposed in this comment

In addition to what was proposed there, I also added .toJSON as an alias for .get.

Motivation and Context

Fixes #2095

How Has This Been Tested?

Added a test just to make sure it works. (I'm not fully convinced it was worth the time to write and run the test, though.)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation change

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated docs/change-log.md

@dead-claudia dead-claudia added the Type: Enhancement For any feature request or suggestion that isn't a bug fix label Oct 29, 2018
@dead-claudia dead-claudia force-pushed the m-prop branch 6 times, most recently from 73c092b to 4d6fbfc Compare October 29, 2018 08:59
@StephanHoyer
Copy link
Member

Where is the implementation of m.prop? Forgot to add?

@dead-claudia
Copy link
Member Author

@StephanHoyer https://github.com/MithrilJS/mithril.js/pull/2268/files#diff-5a33bbbbbbb77492a6d4259fa1b2578e

99% of the diff isn't actually code, but docs updates. m.prop really is that small. 😉

@StephanHoyer
Copy link
Member

Oh, snap.

LGTM! Although I liked the overloaded nature of the old m.prop. But I'm ok with it.

@dead-claudia
Copy link
Member Author

There was some discussion in #2095 suggesting separate get/set functions instead of a single overloaded closure. It's easier to compose and easier to differentiate reads from writes, which is helpful when the prop isn't defined locally.

BTW, this is mostly a port of this minus the observation abilities.

@dead-claudia dead-claudia merged commit 6042b00 into MithrilJS:next Nov 7, 2018
@dead-claudia dead-claudia deleted the m-prop branch November 7, 2018 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement For any feature request or suggestion that isn't a bug fix
Projects
Status: Completed/Declined
Development

Successfully merging this pull request may close these issues.

Bring back m.prop?
2 participants