observable

Android - Can I Databinding programatically? - without layout XML

大憨熊 提交于 2020-02-25 04:47:33
问题 Below is XML equivalent of what I'm trying to achieve, but without XML <Button android:id="@+id/bt_start" android:onClick="@{() -> vm.onClickedStart()}" android:text='@{vm.btStartLbl}' /> so if I have: ConstraintLayout cl = findViewById(R.id.cl); Button btn = new Button(MyActivity.this); btn.setText("How to Data Bind here?"); btn.setOnClickListener(new OnClickListener (){ /* how to databind here? */ }); cl.addView(btn); how to databind it as equivalent as xml above? is it possible? 回答1: For

Size of rectangle in d3js based on sum of values but not count of items

拥有回忆 提交于 2020-02-22 05:29:28
问题 I am working on a d3js visualization where I want to show groups and subgroups based on size.I have most of it working except for the size of the rectangles. If you see on load viz all four box size are of same size because all of them have same no. of grant programs. I want to change the size of these rectangles based on grant_award. Here is the code I have published at : https://gist.github.com/senthilthyagarajan/bfa1b611c0e91b1a304c0b8f32555daf Thank you 回答1: UPDATED:index.js .value() to

Do you have to unsubscribe from a QueryList in a component?

。_饼干妹妹 提交于 2020-02-21 11:06:21
问题 When using the @ContentChildren or @ViewChildren decorators to listen for changes to DOM elements. Do I have to unsubscribe from the QueryList ? For example: @Component({...}) export class ParentComponent implements AfterContentInit { @ContentChildren(ChildComponent) public children: QueryList<ChildComponent>; public ngAfterContentInit(): void { this.children.changes.subscribe(() => ....); } } Would the above be a problem? Updated: The reason I'm asking is that we don't have to unsubscribe to

Do you have to unsubscribe from a QueryList in a component?

只愿长相守 提交于 2020-02-21 11:06:15
问题 When using the @ContentChildren or @ViewChildren decorators to listen for changes to DOM elements. Do I have to unsubscribe from the QueryList ? For example: @Component({...}) export class ParentComponent implements AfterContentInit { @ContentChildren(ChildComponent) public children: QueryList<ChildComponent>; public ngAfterContentInit(): void { this.children.changes.subscribe(() => ....); } } Would the above be a problem? Updated: The reason I'm asking is that we don't have to unsubscribe to

Ionic Events replace with Angular Observables

元气小坏坏 提交于 2020-02-21 06:04:33
问题 I understand Ionic events will be deprecated in next version. Currently I use events to executes functions in my parent page from sub components. Here is an example: In my main page it subscribes to the event to refresh: constructor(){ this.eventFormRefresh = (obj) => { this.fetch(obj.isReset); }; this.events.subscribe('form:refresh', this.eventFormRefresh); } ngOnDestroy(): void { this.events.unsubscribe('form:refresh', this.eventFormRefresh); } In a subcomponent I activate the refresh by

Chaining RxJS Observables from http data in Angular2 with TypeScript

放肆的年华 提交于 2020-02-09 00:39:47
问题 I'm currently trying to teach myself Angular2 and TypeScript after happily working with AngularJS 1.* for the last 4 years! I have to admit I am hating it but I am sure my eureka moment is just around the corner... anyway, I have written a service in my dummy app that will fetch http data from a phoney backend I wrote that serves JSON. import {Injectable} from 'angular2/core'; import {Http, Headers, Response} from 'angular2/http'; import {Observable} from 'rxjs'; @Injectable() export class

How to combine two similar http requests returning Rx Observables?

妖精的绣舞 提交于 2020-02-07 05:35:05
问题 How do I merge 2 separate http requests into one response(join them)? Observable.merge( this.http.get(url1), // [{"city":"New York"},{"city":"Chicago"}] this.http.get(url2) // [{"city":"Washington"},{"city":"Detroit"}] ).subscribe(res => console.log(res.json())) I'm getting two arrays back: [{"city":"New York"},{"city":"Chicago"}], [{"city":"Washington"},{"city":"Detroit"}] What I need is a single array with the combined results: [{"city":"New York"},{"city":"Chicago"},{"city":"Washington"},{

Edit multiple elements in ObservableList and only fire change listeners after last change

天涯浪子 提交于 2020-02-05 06:16:30
问题 I have an ObservableList that doesn't only trigger the registered ListChangeListeners when elements are added or removed, but also when specific Observable attributes within these elements are changed, e.g. a list of persons and when a person's adress changes, the ListChangeListeners fire. How can I edit the adress of multiple people and have the Listeners only fire once for all changes together? 回答1: ObservableList does not provide this functionality by default. If you extend

Edit multiple elements in ObservableList and only fire change listeners after last change

江枫思渺然 提交于 2020-02-05 06:15:18
问题 I have an ObservableList that doesn't only trigger the registered ListChangeListeners when elements are added or removed, but also when specific Observable attributes within these elements are changed, e.g. a list of persons and when a person's adress changes, the ListChangeListeners fire. How can I edit the adress of multiple people and have the Listeners only fire once for all changes together? 回答1: ObservableList does not provide this functionality by default. If you extend

RxJava Observable buffer based on content

佐手、 提交于 2020-02-04 04:57:11
问题 I started a project using vertX and RxJava, and I have a problem for which I don't find a solution. I have an Observable that emits WebSocketFrame for incoming communications, each WebSocketFrame is composed of a payload (a ByteBuffer) and flags that indicates wether it is the first frame of the message or the last. I want to make an operation on this Observable to transform it to an Observable that emits ByteBufferd that contain all the frame of a each message. I tried the buffer method but