Skip to content

feat(service): use of signal #1532

@rbalet

Description

@rbalet

Current behavior

We need to be working with subscription.

Expected behavior

Although this is good the way it is, it could be nicer to add additional signal alternative.

What is the motivation / use case for changing the behavior?

  1. It would let us work with computed variable directly
  2. It will lower the chances of forgotten unsubscription

How do you think that we should implement this?

I can do a PR if needed

I do see two options

1: Additional variable

Inside the translate.service.ts, add of additional signal for reach observable

// Exemple

  $onTranslationChange = toSignal(this.store.onTranslationChange)
  get onTranslationChange(): Observable<TranslationChangeEvent> {
    return this.store.onTranslationChange;
  }

2: Replacement of the former logic

I'd avoid this as this is quite a breaking change

Same as 1. but we remove the onTranslationChange() method. which let you write it as follow.

onTranslationChange = toSignal(this.store.onTranslationChange)

I do personally always use the $ in front of a signal, but standards aren't set yet for the nomenclature

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions