ngx-watcher 基于 Angular6 的数据变化监听服务开源项目

我要开发同款
匿名用户2018年08月13日
87阅读

技术信息

开源地址
https://gitee.com/m310851010/ngx-watcher
授权协议
Apache 2.0

作品详情

gx-watcher

基于agular6实现数据变化监听的service

安装pm istall gx-watcher --save配置

对于agular6项目不需要配置,Ok!

对于agular4,agular5配置app.module.ts文件

@NgModule({  ...  providers: [NgxWatcherService],  ...})export class AppModule { }使用 import {KvWatcher, IterWatcher, NgxWatcherService} from 'gx-watcher'; @Compoet({...})  export class TestCompoet implemets DoCheck {    private kvWatcher: KvWatcher<ay>;   private iterWatcher: IterWatcher<ay>;    value = {}; // keyValue类型   array = []; // 可迭代类型    costructor(private service: NgxWatcherService) {     this.kvWatcher = service.of(this.value);     this.iterWatcher = service.ofIter(this.array);   }    gDoCheck(): void {     this.kvWatcher.watch(       this.value,       v => cosole.log(`chage after value:`, v),       (t, v) => cosole.log(`chaged value: WatchChageType=${t} ${v.key} ${v.previousValue} ${v.curretValue}`)     );      this.iterWatcher.watch(       this.array,       v => cosole.log(`chage after value:`, v),       (t, v) => cosole.log(`chaged value: WatchChageType=${t} ${v.curretIdex} ${v.item} ${v.previousIdex} ${v.trackById}`)     );   } }关于本组件项目

本项目使用AgularCLI versio6.0.7生成

运行项目

使用 gserve启动开发服务.然后打开浏览器输入地址https://localhost:4200/ 即可

编译组件pm ru build:lib

生成编译后的文件在dist/gx-watcher目录

运行效果

LICENSE

Apache-2.0

功能介绍

ngx-watcher 基于angular6实现数据变化监听的service 安装 npm install ngx-watcher --save 配置 对于angular6项目不需要配置, Ok...

示例图片

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论