ค้นหาเว็บไซต์

typescript - RxJS fromEventPattern กับเหตุการณ์ของ React Native

ฉันกำลังพยายามกรองเหตุการณ์ท้องถิ่นใน React Native ด้วย RxJS ฉันกำลังใช้ react-native-ble-manager ซึ่งเปิดเผย EventEmitter โดยพื้นฐานแล้ว โดยไม่ใช้ RxJS ฉันกำลังทำสิ่งต่อไปนี้ (แสดงเฉพาะโค้ดที่เกี่ยวข้องเท่านั้น):

import React from 'react'; import RX from 'reactxp'; import { AppState, Platform, NativeModules, NativeEventEmitter, EmitterSubscription, PermissionsAndroid, ListView } from 'react-native'; import BleManager, { Peripheral } from 'react-native-ble-manag

อ่านต่อไป →

javascript - มีวิธีใดที่จะสมัครสมาชิกอีกครั้งหลังจากยกเลิกการสมัคร RxJS หรือไม่?

นี่คือตัวอย่างโค้ดที่สมัครสมาชิกกับคำขอ Http และยกเลิกเมื่อคลิกเมาส์บนหน้าเว็บ ฉันต้องการสมัครสมาชิกใหม่หากฉันคลิกอีกครั้ง

ฉันสามารถสลับการสมัครสมาชิกได้อย่างไร? FIDDLE

export class AboutComponent implements OnInit { constructor(private http:HttpClient){ } flag=true; documentclick

อ่านต่อไป →

angular - RxJS/Observable: วิธีการกำหนดลำดับสำหรับเมธอด pipe

ฉันมีเมธอด run ในคลาส Some ที่ส่งค่ากลับเป็น Observable และมี pipe อยู่ภายในเมธอดนี้ และฉันก็มี pipe อีกหนึ่งตัวเมื่อเรียกใช้เมธอด run

import { of } from 'rxjs'; import { map, tap, delay } from 'rxjs/operators'; class Some { r

อ่านต่อไป →

javascript - กำลังมองหาบางอย่างเหมือน OrElse ในฟังก์ชัน find ของ angular rxjs ขณะทำการ piping

ฉันมีโค้ดชิ้นต่อไปนี้ สิ่งที่ฉันพยายามทำคือการเปลี่ยนเส้นทางไปยังหน้าที่ไม่พบเมื่อฟังก์ชัน "find" ไม่พบวัตถุคำสั่งใด ๆ ในคำสั่งที่โหลดใน observable

private order: Observable<OrderModel>; ngOnInit() { this.route.params.subscribe(params =

อ่านต่อไป →

angular - วิธีใช้ตัวดำเนินการ "find" ของ rxjs

ฉันต้องการตั้งค่า nameMatch เป็น nodeName หาก nodeName ปรากฏในสตรีมที่สามารถสังเกตได้ เช่นเดียวกันกับ idMatch ฉันกำลังพยายามใช้ตัวดำเนินการ find ของ rxjs นี่คือสิ่งที่ฉันมีอยู่ในตอนนี้:

const response = (this._resourceService.search(ResourceUrns.SERVICE_METRIC) .pipe( map(getServiceNodes)) .subscribe(result => { if (result.find(nodeName)){

อ่านต่อไป →

angular - Rxjs timeout() กำลังแสดงข้อผิดพลาดสำหรับวันที่ในอนาคตบางส่วน

Rxjs timeout() ใช้งานไม่ถูกต้องสำหรับบาง วัน หรือ เวลา

import { interval } from 'rxjs'; import { timeout } from 'rxjs/operators'; const seconds = interval(1000); seconds.pipe( // Present Date (Thu Mar 19 2020 14:40:58) => 1584628858530 // to UTC time & date: (Wed Dec 30 2020 18:30:00) => 1609353000000-------Not working // to UTC time & date: (Mon Dec 30 2030 18:30:00) => 1924885800000-------Working timeout(new Date(160

อ่านต่อไป →

typescript - RxJS - การแปลงโซ่ของ promise เป็น observable ไม่ทำงาน

ฉันกำลังพยายามแปลงการเชนของพรอมิส:

this.tradeTypesLogicService.getList().$promise .then(this.filterTradeTypes) .then(this.setSelectedTradeType)

ไปยัง observable ของ rxjs:

this.tradeTypesLogicService .getList() //returns observable now .pipe(mergeMap(this.filterTradeTypes), map(this.setSelectedTradeType)) .subscribe(); protected filterTradeTypes = (tradeTypes: Array<any>) => { this.tradeTypes = filter(tradeTypes, (

อ่านต่อไป →

javascript - Rxjs รอให้การเรียกใช้งาน interval ก่อนหน้าดำเนินการเสร็จสิ้นก่อนดำเนินการต่อ

กรณีการใช้งาน: เรียกใช้งาน endpoint ทุก 3 นาที ซึ่งจะอัปเดตสถานะของบริการบางอย่างในแอปพลิเคชัน

โค้ดปัจจุบันของฉัน:

interval(180000) .subscribe(() => this.doRequest .pipe(catchError(() => {

อ่านต่อไป →

javascript - ฉันจะรันตรรกะที่ล่าช้าด้วย rxjs หลังจากได้รับค่าจากการสมัครสมาชิกได้อย่างไร?

ฉันต้องการรันบางส่วนของตรรกะของฉันหลังจากการสมัครสมาชิกของฉันพร้อมกับความล่าช้าเพิ่มเติม (ด้วย RxJS) ฉันรู้จักตัวดำเนินการ finalize ซึ่งฉันสามารถใช้กับ pipe ได้ แต่สิ่งนั้นจะทำให้เกิดการดำเนินการทันทีหลังจาก observable ของฉันเสร็จสมบูรณ์

มีวิธีใดท

อ่านต่อไป →

javascript - เราจำเป็นต้องใช้ RXJS combineLatest กับ ActivateRouted.pathFromRoot หรือไม่?

แอปพลิเคชันเอกสาร Angular Material ดึงพารามิเตอร์ของเส้นทางจากโมดูลเส้นทางที่โหลดแบบ lazy ได้ดังนี้:

https://github.com/angular/material.angular.io/blob/master/src/app/pages/component-category-list/component-category-list.ts

// Combine params from all of the path into

อ่านต่อไป →