rxjs

RXJS Drag n drop

空扰寡人 提交于 2019-12-22 07:37:58
问题 This questions relates to RXJS. I'm trying to adapt the drag and drop example in github to work for a class of divs not just a single element ID. https://github.com/Reactive-Extensions/RxJS/blob/master/examples/dragndrop/dragndrop.html simple changes to give the div a class nor an ID dont work and i lose ability to drag the element 3 simple changes: HTML line 7 i.e. <div class="dragTarget">Drag Me!</div> CSS line 1 i.e. .dragTarget { style attributes unchanged } JS line 4 i.e var dragTarget =

RxJS Subjects and Angular 2 components

寵の児 提交于 2019-12-22 06:37:44
问题 I am coming to terms with the fact that web development is changing and I need to get to grips with RxJS. I am currently developing a web app using Angular 2.0.0-beta.15. I am following the most excellent ng-book 2 (is that kind of advertising allowed? Oh well). It covers in broad, shallow strokes some important concepts in RxJS and provides links to further reading. I have read and understood the source code and accompanying explanation, but am left a little in the dark about some details

RxJS: How to have one Observer process multiple Observables?

回眸只為那壹抹淺笑 提交于 2019-12-22 06:30:01
问题 I am working with a framework that calls a function I implement. I would like the parameter of this function to be converted to an Observable, and sent through a sequence of Observers. I thought I could use a Subject for this, but it isn't behaving as I expected. To clarify, I have something like the following code. I thought Option 1 below would work, but so far I am settling for Option 2 , which doesn't seem idiomatic at all. var eventSubject = new Rx.Subject(); var resultSource =

ReactiveX: Group and Buffer only last item in each group

梦想的初衷 提交于 2019-12-22 05:38:10
问题 How to group an Observable, and from each GroupedObservable keep in memory only the last emitted item? So that each group would behave just like BehaviorSubject. Something like this: {user: 1, msg: "Anyone here?"} {user: 2, msg: "Hi"} {user: 2, msg: "How are you?"} {user: 1, msg: "Hello"} {user: 1, msg: "Good"} So in memory we'd have only have the last item for each user : {user: 2, msg: "How are you?"} {user: 1, msg: "Good"} And when a subscriber subscribes, these two items were issued right

Angular material table not showing data

佐手、 提交于 2019-12-22 04:45:46
问题 People who want paging and sorting on client side please refer this link Here is what I tried. The data is loading in the console. but it is not displayed on the grid or mat table. I don't have any error in the console. I am able to see the data in the console but the data is not loaded into the grid. Can somebody tell me what am I doing wrong? The actual database from where data is emitted out. export class FormsDatabase { formsList = new BehaviorSubject([]); get data(){ return this

Should rxjs subjects be public in the class?

吃可爱长大的小学妹 提交于 2019-12-22 04:42:29
问题 Let's say I have two classes, where you can observe over some observables. First example, with public subject: class EventsPub { public readonly onEnd = new Subject<void>(); } Second example, with private subject and registering method: class EventsPriv { private readonly endEvent = new Subject<void>(); public onEnd(cb: () => void): Subscription { return this.endEvent.subscribe(cb); } } The first example is somehow unsafe because anyone can call eventsPub.endEvent.next() from outside the

is there any difference between import { Observable } from 'rxjs/Observable' and import { Observable } from 'rxjs'?

筅森魡賤 提交于 2019-12-22 04:32:07
问题 When using rxjs in angular 2, is there any difference between import { Observable } from 'rxjs/Observable' and import { Observable } from 'rxjs' ? 回答1: Yes there is a slight difference which is the bundle size. If you aren't using tree shaking library like rollup.js which remove all unnecessary codes, your bundle will be large when importing from 'rxjs' as you are importing everything even if you are using only the Observable. On the other hand if you import from 'rxjs/Observable' you are

is there any difference between import { Observable } from 'rxjs/Observable' and import { Observable } from 'rxjs'?

独自空忆成欢 提交于 2019-12-22 04:31:32
问题 When using rxjs in angular 2, is there any difference between import { Observable } from 'rxjs/Observable' and import { Observable } from 'rxjs' ? 回答1: Yes there is a slight difference which is the bundle size. If you aren't using tree shaking library like rollup.js which remove all unnecessary codes, your bundle will be large when importing from 'rxjs' as you are importing everything even if you are using only the Observable. On the other hand if you import from 'rxjs/Observable' you are

rxjs timeout to first value

ⅰ亾dé卋堺 提交于 2019-12-22 04:11:22
问题 so as I understood from this question here I understood that timeout operator errors if an observable does not emit any value in the given window of time... the problem for me is, that this window of time resets after each emit, making it necessary to complete the sequence if you are only interested if the first value(s) emit within the window... is there a nice way to have a "timeout to first"? Other than .take(1).timeout(1000) ? 回答1: In addition to @Maxime's answer, you can use race to

rxjs timeout to first value

流过昼夜 提交于 2019-12-22 04:10:36
问题 so as I understood from this question here I understood that timeout operator errors if an observable does not emit any value in the given window of time... the problem for me is, that this window of time resets after each emit, making it necessary to complete the sequence if you are only interested if the first value(s) emit within the window... is there a nice way to have a "timeout to first"? Other than .take(1).timeout(1000) ? 回答1: In addition to @Maxime's answer, you can use race to