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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bindable): support getter/setter #1753

Merged
merged 6 commits into from May 1, 2023
Merged

feat(bindable): support getter/setter #1753

merged 6 commits into from May 1, 2023

Conversation

bigopon
Copy link
Member

@bigopon bigopon commented Apr 30, 2023

馃摉 Description

resolves #1602

Currently, bindable can only be used with a field, which means the following usages are invalid:

An attribute with a readonly bindable

@customAttribute('my-attr')
class MyAttr {
  private _m = [{ v: 'hello' }, { v: 'world' }];

  @bindable({ mode: BindingMode.fromView })
  get message() {
    return this._m.map(v => v.v).join(' ');
  }
  ...
}

And more similar logics, where a pair of setter/getter are more desirable than a field.

This PR refactors the bindable infra, as well as adds support for the above usage. It does so by treating bindable just as bindable metada for compilation, and enhance existing observers with capabilities to perform work of the bindable observation.
With this work in place, supporting the new decorator proposal will be much easier since we are capable of handle getter/setter from the new auto accessor feature.

馃搼 Test Plan

  • all existing tests should work
  • add new tests for bindable with getters/setters, readonly getter/ coercion + getter/setter

cc @brandonseydel

@bigopon bigopon changed the title feat(bindable): support getter/setter WIP feat(bindable): support getter/setter May 1, 2023
@bigopon bigopon merged commit 4279851 into master May 1, 2023
23 checks passed
@bigopon bigopon deleted the feat/getter-bindable branch May 1, 2023 10:50
AureliaEffect pushed a commit that referenced this pull request May 21, 2023
**BREAKING CHANGE:**

* **compiler:** avoid using au class to find targets (#1768) ([0d30998](0d30998)).
* ***:** rename resolveAll -> onResolveAll (#1764) ([fdf0747](fdf0747))

**Features:**

* **di:** ability to use newInstance()/forScope() with interface (#1767) ([a0d39e9](a0d39e9))
* **all:** allow injection of implementation (#1766) ([a60db13](a60db13))
* **templating:** allow deactivate when activating (#1729) ([1c9c97c](1c9c97c))
* **bindable:** support getter/setter (#1753) ([4279851](4279851))
* **ui-virtualization:** enhance implementation & publish package (#1759) ([7a2f17f](7a2f17f)). Thanks [@Lakerfield](https://github.com/Lakerfield)

**Refactorings:**

* ***:** cleanup up unused code & decouple interface from default impl (#1761) ([7a71d43](7a71d43))
* **router:** add warning for unsupported behavior (#1757) ([ce87339](ce87339)). The router used to allow container traversal to
find resources when a string is used as a route to find the corresponding component.
Going forward this will be invalid and resources must be registered either locally
or globally to be routable. A warning is added first so app that accidentally used
this behavior can detect the invalid usages and fix accordingly first. This behavior will be removed in a near future release.
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.

[feature request]: add getter/setter support for bindable
1 participant