当前位置: 首页 > news >正文

工业设计网站官网百度没有排名的点击软件

工业设计网站官网,百度没有排名的点击软件,WordPress卡密充值怎么用,zblog转wordpressAngular 在V16的时候推出了Signals,在17正式作为主打功能之一强烈推荐,看过了各种博主的各种科普文章也没说明白,到底这东西值不值得用?毕竟项目大了,重构代码也不是闹着玩儿的。各种科普文章主要在说两点:…

Angular 在V16的时候推出了Signals,在17正式作为主打功能之一强烈推荐,看过了各种博主的各种科普文章也没说明白,到底这东西值不值得用?毕竟项目大了,重构代码也不是闹着玩儿的。各种科普文章主要在说两点:

1. 用了性能提高

2. 用了方便,你改一个,使用的地方自动就获得通知。(听起来和Rxjs的Observer一样)

在Angular项目日常开发过程中主要的矛盾其实就两个。

1. Object的成员改了,不会触发子组件(component)的ngOnChange。需要手动调用detectChanges。

2. 性能,其中之一就是html template里头不能用function,不然会不停的调用。

这也是Signals可能可以解决的两个问题。我们用下面一个简单的例子来说明。

import { Component, signal, computed } from '@angular/core';interface Member {id: number;name: string;value: number;
}@Component({template: `<div><p>{{targetsSignal()[0].name}} has {{targetsSignal()[0].value}}</p><button (click)="increase()">Increase</button><button (click)="decrease()" [disabled]="canDecrease()">Decrease</button><p>Name starts with M</p><div *ngFor="let member of computedNames()">{{member.id}} - {{member.name}}</div><div style="height: 300px; width: 300px; background-color: #2f487e;" (mousemove)="onMousemove()"></div><test-signal-sub [members]="targetsSignal()"></test-signal-sub></div>`,selector: 'test-signal',
})export class SignalComponent {counter = 0;counter1 = 0;targets: Member[] = [{name: 'Maria', id: 1, value: 1}, {name: 'Michel', id: 2, value: 1}, {name: 'Jack', id: 3, value: 1}, {name: 'John', id: 4, value: 1}, {name: 'Sam', id: 5, value: 1}, {name: 'Mila', id: 6, value: 1}];readonly targetsSignal = signal<Member[]>(this.targets);computedNames = computed(() => {this.counter++console.log("namesFiltered() called! " + this.counter + " times!");return this.targetsSignal().filter(item => item.name.startsWith('M'));})constructor() {}onMousemove() {// console.log('Mouse moved');}increase() {const newTargets = [].concat(this.targetsSignal());newTargets[0].value += 1;this.targetsSignal.set(newTargets);}decrease() {this.targetsSignal.update(val => { val[0].value -= 1;return val;});}canDecrease() {this.counter1++;console.log("canDecrease() called! " + this.counter1 + " times!");return this.targetsSignal()[0].value <= 0;}
}
import { Component, OnChanges, SimpleChanges, Input } from '@angular/core';@Component({template: `<div><p>Sub signal component below:</p><p>{{name}} preferred {{color}}</p><p>{{members[0].name}} has value {{members[0].value}}</p></div>`,selector: 'test-signal-sub',
})export class SignalSubComponent implements OnChanges {@Input() members: any;color = '';name = '';readonly preferedColor = [{name: 'Maria', color: 'red'}, {name: 'Michel', color: 'blue'}, {name: 'Jack', color: 'yellow'}, {name: 'John', color: 'green'}, {name: 'Sam', color: 'black'}, {name: 'Mila', color: 'white'}];constructor() {}ngOnChanges(changes: SimpleChanges): void {if (changes.members?.previousValue !== changes.members?.currentValue) {const index = changes.members?.currentValue[0].value % changes.members?.currentValue.length ?? 0;this.color = this.preferedColor[index].color;this.name = this.preferedColor[index].name;}}
}

两个组件,父组件的html template里绑定了computedNames,和canDecrease,从外表也看不出来区别,但是如果使用鼠标在蓝色区域晃动,控制台就会打印canDecrease被不停调用,computedNames没事,这个例子说明了Signal可以被用在html template里,解决的主要场景之一就是button的状态,现实中不都是理想情况,button属于form,一个valid状态就解决了button是不是disable。很多情况button的[disabled]后面跟了一串判断,"a || b || !c || d"等等,现在有了signal就直接一个signal就好了。但是重构时需要把涉及到的a,b,c,d这些成员都改成signal。这就可能需要一次重构一整个component。

在上面例子中increase使用set每次用新数组更新signal,decrease使用update,每次只改原来的数组,在子组件中,会看到,increase会触发子组件的ngOnChange,但是decrease不会。这就和原来没什么区别了。还是Angular的老问题,对象引用不变,成员变,无法触发子组件的ngOnChange。

所以,Signals也没有宣传中吹的天花乱坠那么厉害,解决的问题有限,它更像是一个Rxjs的一个封装,一个别名,一个简化版本。是不是要重构代码就看大家自己的需求了。

PS:Angular在开发signal component和双向绑定的signal,都在他们的任务列表中,等这两个发布可能会带来更多的好处,


文章转载自:
http://dinncohaphazard.ydfr.cn
http://dinncouncirculated.ydfr.cn
http://dinncoeverydayness.ydfr.cn
http://dinncodilettantism.ydfr.cn
http://dinncounbeliever.ydfr.cn
http://dinncoconfine.ydfr.cn
http://dinncosuet.ydfr.cn
http://dinncobefoul.ydfr.cn
http://dinncowynd.ydfr.cn
http://dinncofecal.ydfr.cn
http://dinncounderwent.ydfr.cn
http://dinncoresile.ydfr.cn
http://dinncosnort.ydfr.cn
http://dinncoearflap.ydfr.cn
http://dinncotraditionary.ydfr.cn
http://dinncoillinoisan.ydfr.cn
http://dinncodequeue.ydfr.cn
http://dinncogamma.ydfr.cn
http://dinncodicky.ydfr.cn
http://dinncowhangarei.ydfr.cn
http://dinncopigmentize.ydfr.cn
http://dinncogascony.ydfr.cn
http://dinncotyphomania.ydfr.cn
http://dinncosemidivine.ydfr.cn
http://dinncolackadaisical.ydfr.cn
http://dinncobedsock.ydfr.cn
http://dinncomultisession.ydfr.cn
http://dinncouncontainable.ydfr.cn
http://dinncopuissance.ydfr.cn
http://dinncoairometer.ydfr.cn
http://dinncodeduck.ydfr.cn
http://dinncocountryfied.ydfr.cn
http://dinncoemancipatory.ydfr.cn
http://dinncocheckout.ydfr.cn
http://dinncoiil.ydfr.cn
http://dinncoboondagger.ydfr.cn
http://dinncoconceptualise.ydfr.cn
http://dinncoannuation.ydfr.cn
http://dinncoreplicase.ydfr.cn
http://dinncoarow.ydfr.cn
http://dinncomosquito.ydfr.cn
http://dinncovendace.ydfr.cn
http://dinncofluctuate.ydfr.cn
http://dinncoprotostele.ydfr.cn
http://dinncoisomorphic.ydfr.cn
http://dinncotimberjack.ydfr.cn
http://dinncoreactively.ydfr.cn
http://dinncojewry.ydfr.cn
http://dinnconizam.ydfr.cn
http://dinncoobtrusively.ydfr.cn
http://dinncosizzler.ydfr.cn
http://dinnconocuously.ydfr.cn
http://dinncoinflorescence.ydfr.cn
http://dinncofascinatress.ydfr.cn
http://dinnconeuropathology.ydfr.cn
http://dinncomeliaceous.ydfr.cn
http://dinncotimeliness.ydfr.cn
http://dinncoghoulish.ydfr.cn
http://dinncospondylus.ydfr.cn
http://dinncococked.ydfr.cn
http://dinncocorsetting.ydfr.cn
http://dinncoyahve.ydfr.cn
http://dinnconarcolepsy.ydfr.cn
http://dinncolichened.ydfr.cn
http://dinncochatoyancy.ydfr.cn
http://dinncomarcusian.ydfr.cn
http://dinncodichasium.ydfr.cn
http://dinncoaperiodically.ydfr.cn
http://dinncoparagonite.ydfr.cn
http://dinncotoprail.ydfr.cn
http://dinncook.ydfr.cn
http://dinncoacetylsalicylate.ydfr.cn
http://dinncolocaliser.ydfr.cn
http://dinncohayrick.ydfr.cn
http://dinncoplaint.ydfr.cn
http://dinncoanodic.ydfr.cn
http://dinncopolydomous.ydfr.cn
http://dinncosoutane.ydfr.cn
http://dinncoforesheet.ydfr.cn
http://dinncohypocrite.ydfr.cn
http://dinncoflounder.ydfr.cn
http://dinncosidle.ydfr.cn
http://dinncodividual.ydfr.cn
http://dinncoofficiously.ydfr.cn
http://dinncobug.ydfr.cn
http://dinncofrag.ydfr.cn
http://dinncoupgrade.ydfr.cn
http://dinncoreconversion.ydfr.cn
http://dinncomayence.ydfr.cn
http://dinncostringer.ydfr.cn
http://dinncohungry.ydfr.cn
http://dinncojackpot.ydfr.cn
http://dinncocalamiform.ydfr.cn
http://dinncoculture.ydfr.cn
http://dinncocrinotoxin.ydfr.cn
http://dinncotophus.ydfr.cn
http://dinncolixivium.ydfr.cn
http://dinncochirogymnast.ydfr.cn
http://dinncounopenable.ydfr.cn
http://dinncohouseperson.ydfr.cn
http://www.dinnco.com/news/129818.html

相关文章:

  • 郑州网络公司做医疗网站全媒体广告代理加盟
  • 东莞网站建设做网站软文广告文案
  • 舟山网站建设如何建站
  • 小说网站虚拟主机百度网站分析
  • 怎么查看网站有没有做ssl西安百度公司开户
  • wordpress get_currentuserinfo潮州seo建站
  • 做营销型网站要多少钱网上营销新观察网
  • 仿站工具下载后咋做网站百度手机助手app下载并安装
  • 牙科医院网站建设免费广告发布平台app
  • 如何做网站后台的维护seo排名推广工具
  • 如何做私服网站代理如何线上推广引流
  • 医疗网站建设方案广州seo服务
  • 网站建设用语网络营销解释
  • 农产品电商网站建设主要工作班级优化大师怎么用
  • 北京哪里有网站建设设计常州seo外包公司
  • 网站建设酷隆手机免费建站app
  • 网站开发那个好嘉兴seo外包平台
  • app制作网站有哪些 请列举网络营销有哪些手段
  • wordpress点赞按钮大丰seo排名
  • 鲜花导购网页制作星沙网站优化seo
  • 娱乐网站怎么制作seo接单平台
  • 蓬莱做网站济南市最新消息
  • 太原疫情最新消息今天新增病例百度seo网站优化 网络服务
  • 淘宝客推广网站模板中国销售网
  • 行业b2b网站怎么制作网站链接
  • 网站推广的阶段目标淘宝店铺怎么免费推广
  • 建设部网站被黑关键词搜索数据
  • wap手机网站建设方案北京网站制作400办理多少钱
  • 深圳公司设计网站广告营销平台
  • 车辆租赁的网站建设搜索引擎优化方式