aurelia / aurelia/store

Selector and Action Property Decorators Proposal

Open
#83 16 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
100
Forks
22
PR merge metrics
No merged PRs in 30d

Description

**I'm submitting a feature request**

* **Browser:**
all

* **Language:**
all

**Current behavior:**
There are no property decorators

**Expected/desired behavior:**

* **What is the expected behavior?**

Some ideas for these selectors include, but not limited to:

The **select** decorator
_Should_:
🔲 Subscribe to the store when the view model is added
🔲 Select the slice of state
🔲 Call the change handler method after the value is set
🔲 Unsubscribe to the store when the view model is removed
_Could_:
🔲 Pass additional props
🔲 Pass the view model as additional props
🔲 Pass an observable
🔲 Pass a POJO
🔲 Compare the two values with the default `===` before running the change handling

The **action** decorator
_Should_:
🔲 Register the action when the view model is added
🔲 Unregister the action when the view model is removed

* **What is the motivation / use case for changing the behavior?**
With `connectTo` you have to create a property anyway with typescript or you will get a compile time error. There is no way to register actions with the store automatically in the background, similar to `mapToDispatch` with redux. I am sure there are others i am missing...

This should also satisify #69 without introducing a breaking change to the `connectTo` decorator.

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing connectTo decorator and the mapToDispatch pattern referenced in the issue. Determine how selector and action decorators should register and unregister with the store, handle selection changes, and invoke change handlers. Done means the proposed behavior is specified and covered for view-model lifecycle and property updates.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.