async管道引用导致无限循环。
创始人
2024-09-21 03:01:18
0

当async管道引用对象是可变的(如Observable或Promise)时,它可能引起无限循环,并最终导致应用程序崩溃。要解决这个问题,可以使用一种名为“async管道引用”的技术,它确保每个值只被订阅一次。以下是使用该技术的示例代码:

@Component({
  selector: 'app-example',
  template: `
    
{{item}}
` }) export class ExampleComponent { items$: Observable; constructor(private someService: SomeService) { this.items$ = this.someService.getItems(); } } @Pipe({ name: 'asyncRef' }) export class AsyncRefPipe implements PipeTransform { private subscription: Subscription; transform(value: Observable): Observable { if (!this.subscription) { this.subscription = value.subscribe(); } return value; } }

相关内容

热门资讯

透视规律!德普之星app安卓版... 透视规律!德普之星app安卓版破解版,hhpoker透视下载链接在哪里,每日必看教程(有挂黑科技)1...
透视攻略!aapoker透视插... 透视攻略!aapoker透视插件,hhpoker透视脚本,解密教程(一贯是真的有挂)1、让任何用户在...
透视好友!wepoker免费永... 透视好友!wepoker免费永久脚本,aapoker透视脚本下载,发现一款(有挂技巧)是一款可以让一...
透视教学!wepoker辅助下... 透视教学!wepoker辅助下载,wepoker有机器人吗,德州教程(最初是真的有挂)这是由厦门游乐...
透视脚本!aapoker有脚本... 透视脚本!aapoker有脚本吗,wpk脚本辅助器,揭秘攻略(有挂方法)1、很好的工具软件,可以解锁...
透视工具!aapoker辅助功... 透视工具!aapoker辅助功能,来玩德州破解器,规律教程(原先有挂);小薇(透视辅助)致您一封信;...
透视规律!wepoker辅助透... 1、透视规律!wepoker辅助透视软件,hhpoker免费透视脚本,一分钟揭秘(有挂详情);代表性...
透视有挂!aapoker辅助插... 透视有挂!aapoker辅助插件工具,hhpoker透视工具,技巧教程(原来真的有挂);1分钟了解详...
透视辅助!德朴之星脚本,德普之... 透视辅助!德朴之星脚本,德普之星辅助正版,终于发现(有挂辅助挂)1、实时德普之星辅助正版开挂更新:用...
透视软件!aapoker可以开... 透视软件!aapoker可以开挂吗,aapoker怎么提高中牌率,爆料教程(最初真的是有挂)1、不需...