-
Notifications
You must be signed in to change notification settings - Fork 23
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
Changes from 12 commits
dd72844
20771dc
277829b
7ccdca9
6339e90
a893833
743dcfd
6109eab
7f2e696
e6bc5a5
a854447
e370598
14a6494
513744d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just a tiny typo here, |
||
testElement.computedString = "new value"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i guess this should be setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
const propValue = testElement.computedString; | ||
chai.assert.equal(propValue, 'computed yahoo'); | ||
}); | ||
|
||
test('observer property function should be invoked', function() { | ||
testElement.observedString = "new value"; | ||
const propValue = testElement.lastChange; | ||
chai.assert.equal(propValue, 'new value'); | ||
}); | ||
|
||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
const {customElement, property, query, queryAll, observe} = Polymer.decorators; | ||
|
||
|
@@ -18,9 +18,6 @@ class TestElement extends Polymer.Element { | |
@property({notify: true}) | ||
aNum: number = 42; | ||
|
||
@property() | ||
doesntNotify: boolean = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
@property({notify: true}) | ||
aString: string = 'yes'; | ||
|
||
|
@@ -32,12 +29,20 @@ class TestElement extends Polymer.Element { | |
|
||
@property({readOnly:true}) | ||
readOnlyString: string; | ||
|
||
@property({computed:'computeString(reflectedString)'}) | ||
computedString: string; | ||
|
||
@property({observer:'observeString'}) | ||
observedString: string; | ||
|
||
// stand-in for set function dynamically created by Polymer on read only properties | ||
_setReadOnlyString: (value: string) => void; | ||
|
||
lastNumChange: number; | ||
|
||
lastChange: string; | ||
|
||
lastMultiChange: any[]; | ||
|
||
@query('#num') | ||
|
@@ -60,4 +65,12 @@ class TestElement extends Polymer.Element { | |
private _numStringChanged(newNum: number, newString: string) { | ||
this.lastMultiChange = [newNum, newString]; | ||
} | ||
|
||
private computeString(s:string) { | ||
return "computed " + s; | ||
} | ||
|
||
private observeString(s:string) { | ||
this.lastChange = s; | ||
} | ||
} |
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.
Can you move both items to the
unreleased
section and remove these alpha releases?