Skip to content

Conversation

@hoebbelsB
Copy link
Member

@hoebbelsB hoebbelsB commented Feb 26, 2023

Description

https://hackmd.io/gf5D1kC0RVKfDrJZXY-V0Q

State

  • connect accepts signals
  • get computed from state
  • read signal from state
  • create effect from state
// component state
private state = inject<RxState<{ todos: Todo[]; foo: string}>>(RxState);

Connect a signal

const todos: Signal<Todo[]> = signal(todoData);
this.state.connect('todos', todos);

Computed from state

// takes a function that gets each property of the state as `Signal<T[K]>`.
// in this case, todos will be `Signal<Todo[]>`

const count: Signal<number> = this.state.computed(({ todos }) => {
    return todos().length;
});

Signal from state

const todosSignal: Signal<Todo[]> = this.state.signal('todos');

Effect from state

const _effect: Effect = this.state.effect(({ todos }) => {
   if (todos().length > 20) {
      console.log('something was added');
    }
});

To be discussed

  • proxy object for easier access

Template

  • rxLet accepts signal
  • rxFor accepts signal
  • rxIf accepts signal
  • push pipe accepts signal

To be discussed

  • introduce transition like API (as in react concurrent mode) to have a scheduled signal using RxRenderStrategies internally?

@nx-cloud
Copy link

nx-cloud bot commented Feb 26, 2023

☁️ Nx Cloud Report

We didn't find any information for the current pull request with the commit 4e2a373.
You might need to set the 'NX_BRANCH' environment variable in your CI pipeline.

Check the Nx Cloud Github Integration documentation for more information.


Sent with 💌 from NxCloud.

@github-actions github-actions bot added the { } State @rx-angular/state related label Feb 26, 2023
@github-actions github-actions bot added the </> Template @rx-angular/template related label Apr 12, 2023
import { RxStrategyProvider } from '@rx-angular/cdk/render-strategies';
import { Subject } from 'rxjs';

@Directive({ selector: '[signalLet]', standalone: true })
Copy link
Member

Choose a reason for hiding this comment

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

At this point, I'd just call it let directive as signals are going to be the recommended approach going forward

Copy link
Member

Choose a reason for hiding this comment

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

I would reconsider the ideas in the template in general. The recent releases change a lot and we should adopt to the "modern way".

}
}

function toObservable<T>(input: Signal<T>): Observable<T> {
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to remove this in favor of Angular's toObservable?

get<K extends keyof T>(
target: SignalStore<T>,
p: K | string | symbol
): Signal<T[K]> {
Copy link
Member

Choose a reason for hiding this comment

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

Here we say Signal<T[K]> but in the initialValue we have signal(val ?? null)

Do we want to have it as Signal<T[K] | null> ?

@edbzn edbzn mentioned this pull request Oct 17, 2023
@hoebbelsB hoebbelsB closed this Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

{ } State @rx-angular/state related </> Template @rx-angular/template related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants