Is there a way to use Angular Signals outside Angular, in a regular Typescript project?

huangapple go评论50阅读模式
英文:

Is there a way to use Angular Signals outside Angular, in a regular Typescript project?

问题

I'm wondering if there is a way to import just the angular signals in a typescript project, so that I could keep using the same syntax and semantic in other projects, instead of having to install different signals libs.

英文:

I'm wondering if there is a way to import just the angular signals in a typescript project, so that I could keep using the same syntax and semantic in other projects, instead of having to install different signals libs..

答案1

得分: 2

Angular信号是Angular的一部分,以下是Signal RFC的引用。

"我们确实讨论了发布独立的信号库的可能性,但最初没有这样做的原因是:

  • 它仍处于早期阶段,我们不希望在通过RFC反馈并确定确切的API形状之前发布。
  • 该库的某些部分与Angular内部深度集成(效果调度和清理是最明显的示例)。
  • 发布新包存在一些实际摩擦。如果有价值,我们肯定会考虑发布一个单独的NPM包 - 如果您希望将Angular信号库作为一个单独的NPM包提供,请在RFC中留下反馈。"

这意味着信号不应该在Angular之外使用,因为它们是Angular的一个组成部分。

不过,您可以使用其他信号库。

英文:

The Angular signals are part of Angular, here is a quote of the Signal RFC.

> We did discuss the possibility of publishing an independent signal
> library but didn't do so initially for the following reasons:
>
> it is still in the early stages and we don't want to publish before
> going through the RFC feedback and settling on the exact API shape
> there are parts of the library that deeply integrate with the Angular
> internals (effects scheduling and cleanup is the most notable example)
> there is some practical friction in publishing a new package We will
> definitely consider publishing a separate NPM package if there is
> value in it - please leave feedback in the RFC if you would like to
> see Angular signals library to be available as a separate NPM package.

This means the signals are not meant to be used outside Angular because they are an integral part of Angular.

There are other Signal libraries you could use though.

huangapple
  • 本文由 发表于 2023年5月25日 22:52:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/76333629.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定