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 "computed" and "observer" attribute to @property decorator #18

Merged
merged 14 commits into from
Dec 27, 2017

Conversation

danielvanmil
Copy link
Contributor

Add @computedProperty decorator

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@danielvanmil
Copy link
Contributor Author

I signed it!

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@43081j
Copy link
Contributor

43081j commented Nov 21, 2017

This should probably be renamed as its actually support for computed in the @property decorator, rather than a standalone decorator.

Looks good though, nice PR 👍

@@ -38,6 +38,7 @@ export interface PropertyOptions {
notify?: boolean;
reflectToAttribute?: boolean;
readOnly?: boolean;
computed: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be optional like the others

@43081j 43081j mentioned this pull request Nov 22, 2017
@danielvanmil danielvanmil changed the title Add @computedProperty decorator Add @computed attribute to @property decorator Nov 23, 2017
@danielvanmil danielvanmil changed the title Add @computed attribute to @property decorator Add "computed" attribute to @property decorator Nov 23, 2017
@danielvanmil danielvanmil changed the title Add "computed" attribute to @property decorator Add "computed" and "observer" attribute to @property decorator Nov 28, 2017
@43081j
Copy link
Contributor

43081j commented Dec 19, 2017

@aomarks can we get this merged?

@danielvanmil can you rebase onto master to resolve the conflicts? maybe while you're in here too, it could be worth adding value to PropertyOptions as that is missing too (i guess its any).

CHANGELOG.md Outdated
@@ -2,6 +2,12 @@

## [Unreleased]

## [0.1.2-alpha.2] - 2017-11-28
- Added "observer" attribute to @property annotation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move both items to the unreleased section and remove these alpha releases?

bower.json Outdated
@@ -1,7 +1,7 @@
{
"name": "polymer-decorators",
"homepage": "https://github.com/Polymer/polymer-decorators",
"version": "0.1.1",
"version": "0.1.2-alpha.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't modify version.

package.json Outdated
@@ -1,6 +1,6 @@
{
"name": "@polymer/decorators",
"version": "0.1.1",
"version": "0.1.2-alpha.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't modify version.

@@ -52,7 +54,9 @@ export function property(options?: PropertyOptions) {
const reflectToAttribute: boolean =
options && options.reflectToAttribute || false;
const readOnly: boolean = options && options.readOnly || false;

const computed: string = options && options.computed || "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you run npm run format? Should switch quotes to single.

@danielvanmil danielvanmil reopened this Dec 27, 2017
@danielvanmil
Copy link
Contributor Author

rebased

@danielvanmil
Copy link
Contributor Author

processed "code review"

@danielvanmil
Copy link
Contributor Author

@43081j: please merge

@@ -74,6 +74,18 @@ suite('TypeScript Decorators', function() {
const propValue = testElement.readOnlyString;
chai.assert.equal(propValue, 'initial value');
});

test('computed property should should return computed value', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a tiny typo here, should should

@@ -74,6 +74,18 @@ suite('TypeScript Decorators', function() {
const propValue = testElement.readOnlyString;
chai.assert.equal(propValue, 'initial value');
});

test('computed property should should return computed value', function() {
testElement.computedString = "new value";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess this should be setting reflectedString to yahoo? so the following computed result is computed yahoo? by the looks of the test element source.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@@ -9,7 +9,7 @@
* rights grant found at http://polymer.github.io/PATENTS.txt
*/

/// <reference path="../bower_components/polymer-decorators/global.d.ts" />
/// <reference path="bower_components/polymer-decorators/global.d.ts" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your build fails because this path can't be found, probably just needs setting back to ../?

@@ -18,9 +18,6 @@ class TestElement extends Polymer.Element {
@property({notify: true})
aNum: number = 42;

@property()
doesntNotify: boolean = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a failing test causing your build to fail which depends on this. maybe just restore this property

@43081j
Copy link
Contributor

43081j commented Dec 27, 2017

added a couple of comments to help you get the CI build passing. but other than those small changes, looks good to me.

@aomarks can merge if he approves too

@aomarks aomarks merged commit d6b3fa3 into Polymer:master Dec 27, 2017
@aomarks
Copy link
Member

aomarks commented Dec 27, 2017

Merged. Thanks @danielvanmil and @43081j !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants