Skip to content

Commit e7825eb

Browse files
RobertHerholdjdanyow
authored andcommitted
feat(observable): add propertyName argument
1 parent 044746f commit e7825eb

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/decorator-observable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function observable(targetOrConfig: any, key: string, descriptor?: Proper
3434
let oldValue = this[innerPropertyName];
3535
this[innerPropertyName] = newValue;
3636
if (this[callbackName]) {
37-
this[callbackName](newValue, oldValue);
37+
this[callbackName](newValue, oldValue, key);
3838
}
3939
};
4040

test/decorator-observable.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('observable decorator', () => {
1414
spyOn(instance, 'valueChanged');
1515

1616
instance.value = newValue;
17-
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, oldValue);
17+
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, oldValue, 'value');
1818
});
1919

2020
it('should call valueChanged when changing the undefined property', () => {
@@ -25,7 +25,7 @@ describe('observable decorator', () => {
2525
spyOn(instance, 'valueChanged');
2626

2727
instance.value = newValue;
28-
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, undefined);
28+
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, undefined, 'value');
2929
});
3030

3131
it('should call customHandler when changing the property', () => {
@@ -36,7 +36,7 @@ describe('observable decorator', () => {
3636
spyOn(instance, 'customHandler');
3737

3838
instance.value = newValue;
39-
expect(instance.customHandler).toHaveBeenCalledWith(newValue, oldValue);
39+
expect(instance.customHandler).toHaveBeenCalledWith(newValue, oldValue, 'value');
4040
});
4141

4242
it('should call customHandler when changing the undefined property', () => {
@@ -47,7 +47,7 @@ describe('observable decorator', () => {
4747
spyOn(instance, 'customHandler');
4848

4949
instance.value = newValue;
50-
expect(instance.customHandler).toHaveBeenCalledWith(newValue, undefined);
50+
expect(instance.customHandler).toHaveBeenCalledWith(newValue, undefined, 'value');
5151
});
5252

5353
it('should work when valueChanged is undefined', () => {
@@ -81,7 +81,7 @@ describe('observable decorator', () => {
8181
spyOn(instance, 'valueChanged');
8282

8383
instance.value = newValue;
84-
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, oldValue);
84+
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, oldValue, 'value');
8585
});
8686

8787
it('should work with decorators function when property is undefined', () => {
@@ -92,7 +92,7 @@ describe('observable decorator', () => {
9292
spyOn(instance, 'valueChanged');
9393

9494
instance.value = newValue;
95-
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, undefined);
95+
expect(instance.valueChanged).toHaveBeenCalledWith(newValue, undefined, 'value');
9696
});
9797

9898
it('should work with decorators function and config', () => {
@@ -106,6 +106,6 @@ describe('observable decorator', () => {
106106
spyOn(instance, 'customHandler');
107107

108108
instance.value = newValue;
109-
expect(instance.customHandler).toHaveBeenCalledWith(newValue, oldValue);
109+
expect(instance.customHandler).toHaveBeenCalledWith(newValue, oldValue, 'value');
110110
});
111111
});

0 commit comments

Comments
 (0)