當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。