当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript operators.distinct函数代码示例

本文整理汇总了TypeScript中rxjs/operators.distinct函数的典型用法代码示例。如果您正苦于以下问题:TypeScript distinct函数的具体用法?TypeScript distinct怎么用?TypeScript distinct使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了distinct函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

  it('should emit unique array instances with the default projection', () => {
    const e1 =   hot('-a--b--|');
    const e2 =   hot('--1--2-|');
    const expected = '-------(c|)';

    const result = e1.pipe(
      combineLatest(e2),
      distinct(),
      count()
    );

    expectObservable(result).toBe(expected, { c: 3 });
  });
开发者ID:DallanQ,项目名称:rxjs,代码行数:13,代码来源:combineLatest-spec.ts

示例2: buscarTipos

function buscarTipos(propiedad: string, arreglo: Character[]) {
    const arregloRepetido = arreglo.map(
        (caracter) => {
            return caracter[propiedad];
        }
    );

    return rxjs.of(arregloRepetido)
        .pipe(
            distinct()
        )


}
开发者ID:2018-B-GR1-AplicacionesWeb,项目名称:Tamayo-Edison,代码行数:14,代码来源:01-examen.ts

示例3: higherOrder

export function distinct<T, K>(this: Observable<T>,
                               keySelector?: (value: T) => K,
                               flushes?: Observable<any>): Observable<T> {
  return higherOrder(keySelector, flushes)(this);
}
开发者ID:DallanQ,项目名称:rxjs,代码行数:5,代码来源:distinct.ts

示例4: constructor

  constructor($args: { mqttUrl: string; name: string }, $log: Ha4usLogger) {
    const url = new URL($args.mqttUrl)
    $log.info(
      `Connecting to ${url.protocol}//${url.username}@${url.host} as ${
      $args.name
      }`
    )
    const mqtt = Mqtt.connect(
      $args.mqttUrl,
      {
        clientId:
          $args.name +
          '_' +
          Math.random()
            .toString(16)
            .substr(2, 8),
        rejectUnauthorized: false,
        will: {
          topic: $args.name + '/connected',
          payload: '0',
          qos: 0,
          retain: true,
        },
      }
    )

    mqtt.once('connect', () => {
      this.connected = 1
      this.$log.info('Connected as %s', mqtt.options.clientId)
    })
    mqtt.on('error', function (err) {
      $log.error('Error mqtt', err)
    })

    mqtt.on('close', function () {
      $log.warn('closing mqtt')
    })

    super(mqtt)

    this.mqtt = mqtt
    this.$log = $log
    this.caching$ = new ReplaySubject(1)

    this.cache$ = this.caching$.pipe(
      distinct(), // only add if not already in there
      mergeMap(topic => this.observe(topic)), // observe the new topic
      scan((acc: Map<string, Ha4usMessage>, msg: Ha4usMessage) => {
        acc.set(msg.topic, msg)
        return acc
      }, new Map<string, Ha4usMessage>()),
      shareReplay()
    )

    this.cache$.subscribe(cache => {
      debug(`cache updated ( size: ${cache.size})`)
      this.cache = cache
    })

    this.domain = $args.name
  }
开发者ID:ha4us,项目名称:ha4us.old,代码行数:61,代码来源:state.service.ts

示例5: Date

//02-observables.ts
//import{}from 'rxjs';
declare var require;
//declare var module:any;
const rxjs=require('rxjs');
const map=require('rxjs/operators').map;
const disctint=require('rxjs/operators').distinct;


const observableUno$=rxjs.of([1,2,3],'Hola',3,true,{nombre: 'Adrian'},new Date(),3,3, 3,);
console.log(observableUno$);
observableUno$
    .pipe(
        disctint(),
        map(
            (valor)=>{
                console.log('Valor',valor);
                return {data: valor};
            }
        )

    )
.subscribe(
    (ok)=>{
        console.log('En ok',ok);
    },
    (error)=>{
        console.log(error);
    },
    ()=>{
        console.log('completado');
开发者ID:2018-B-GR1-AplicacionesWeb,项目名称:mejia-lopez-franklin-david,代码行数:31,代码来源:02-obvservables.ts

示例6: require

//04  ../02-observables

declare var require: NodeRequire;
const rxjs = require('rxjs');
//inquirer.js
const map = require('rxjs/operators').map;
const distinct = require('rxjs/operators').distinct;
const obsevableUno$ = rxjs.of(1, [1, 2, 3], 'hola', {nombre: 'javier'}, new Date(), 1, 5, 1);

console.log(obsevableUno$);
obsevableUno$

    .pipe(
        distinct(),
        map((valor) => {
            console.log('Valor', valor);
            return {data: valor};
        })
    ).pipe() //en .susbcribe  allĂ­ ya se ejecuta la funcion
    .subscribe((ok) => {//el .then se ejecuta Aqui
        console.log("ok :", ok);
    }, (error) => {//aqui caerĂ­a la promesa con error
        console.log(error);
    }, () => {
        console.log('compleado');
    });

//////  ej de otra promesa


const promesita = () => {
开发者ID:2018-B-GR1-AplicacionesWeb,项目名称:Beltran-Venegas-Daniel-Alexander,代码行数:31,代码来源:02-observables.ts

示例7: it

it('should accept a keySelector', () => {
  interface Person { name: string; }
  const o = of<Person>({ name: 'Tim' }).pipe(distinct(person => person.name)); // $ExpectType Observable<Person>
});
开发者ID:jaychsu,项目名称:RxJS,代码行数:4,代码来源:distinct-spec.ts

示例8: disctinct

 (contenidoArchivo) => {
     const obj = (contenidoArchivo);
     //const obj2 = (obj['ListaCanciones']);
     const datos = rxjs.of(obj);
     const observable$ = (datos);
     observable$
         .pipe(
             disctinct(),
             map(
                 (valor) => {
                     console.log('Valor', valor);
                     return {
                         data:JSON.parse(valor)
                     };
                 }
             )
         )
         .subscribe(
             (ok) => {
                 console.log('Fin');
             },
             (error) => {
                 console.log(error);
             },
             () => {
                 console.log('Completado');
             }
         );
 }
开发者ID:2018-B-GR1-AplicacionesWeb,项目名称:Chinacalle-Paredes-Analy-Belen,代码行数:29,代码来源:metodosPromesasObservables.ts

示例9: Date

    [1, 2, 3],
    3,
    'Hola',
    3,
    true,
    3,
    {nombre: 'Adrian'},
    new Date(),
    3,
);

console.log(observableUno$);

observableUno$
    .pipe(
        disctinct(),
        map(
            (valor) => {
                console.log('Valor', valor);
                return {
                    data: valor
                };
            }
        )
    )
    .pipe(

    )
    .pipe(

    )
开发者ID:2018-B-GR1-AplicacionesWeb,项目名称:alvarez-naranjo-miguel-esteban,代码行数:31,代码来源:02-observables.ts


注:本文中的rxjs/operators.distinct函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。