- https://stackblitz.com/angular/lrgbklxpqal?file=src%2Fapp%2Fapp-routing.module.ts
- https://www.google.com/search?ei=4YGsXJPIMs62mAX_8bvgCQ&q=how+can+i+custom+modal+in+angular+6&oq=how+can+i+custom+modal+in+angular+6&gs_l=psy-ab.3..33i22i29i30.3557405.3574626..3574895...9.0..0.134.3190.17j15......0....1..gws-wiz.......0i131j0j0i10j0i22i30.l8doNrBNJwE
- https://medium.freecodecamp.org/everything-you-need-to-know-about-ng-template-ng-content-ng-container-and-ngtemplateoutlet-4b7b51223691
RxJS, Obserable, subscribe, subscription,
Obserable vs promise
https://morioh.com/p/726c7646cc64 (*************** VVVVI)how to use combine latest - you can pass as array or without array see the bellow example
combineLatest(
[this.FBD.iterateReferencesByChild('facilityData/' + this._currentFacility + '/tasks', 'parent/device', deviceId),
this.FBD.iterateReferencesByChild('facilityData/' + this._currentFacility + '/components', 'parent/device', deviceId),
this.FBD.iterateReferencesByChild('facilityData/' + this._currentFacility + '/attachments', 'parent/device', deviceId),
this.FBD.iterateReferencesByChild('facilityData/' + this._currentFacility + '/comments', 'parent/device', deviceId)]
).pipe(take(1)).subscribe((refArrays) => {
console.log("testing ",refArrays);
let referencePaths = [].concat.apply([], refArrays);
for (let i = referencePaths.length - 1; i >= 0; i--) {
references[referencePaths[i]] = null;
}
references['facilityData/' + this._currentFacility + '/devices/' + deviceId] = null;
this.logHelperService.markRemovedEvents(deviceId, '_deviceIndex');
Object.keys(references).forEach(element => {
// console.log(element);
const itemsRef = this.ngFireDb.list(element);
itemsRef.remove();
});
callback('done');
});
deleteDevice(deviceId, callback) {
let references = {};
combineLatest(
this.FBD.iterateReferencesByChild('facilityData/' + this._currentFacility + '/tasks', 'parent/device', deviceId),
this.FBD.iterateReferencesByChild('facilityData/' + this._currentFacility + '/components', 'parent/device', deviceId),
this.FBD.iterateReferencesByChild('facilityData/' + this._currentFacility + '/attachments', 'parent/device', deviceId),
this.FBD.iterateReferencesByChild('facilityData/' + this._currentFacility + '/comments', 'parent/device', deviceId)
).pipe(take(1)).subscribe((refArrays) => {
let referencePaths = [].concat.apply([], refArrays);
for (let i = referencePaths.length - 1; i >= 0; i--) {
references[referencePaths[i]] = null;
}
references['facilityData/' + this._currentFacility + '/devices/' + deviceId] = null;
this.logHelperService.markRemovedEvents(deviceId, '_deviceIndex');
Object.keys(references).forEach(element => {
// console.log(element);
const itemsRef = this.ngFireDb.list(element);
itemsRef.remove();
});
callback('done');
});
}
combine latest with another api call in pipe
getFacilitiesByUser(uid) {
return this.getFacilityRightsByUser(uid).snapshotChanges().pipe(
switchMap((data: any) => {
return combineLatest(
// of(data),
combineLatest(data.map(item => {
return this._getFacilityObject(item.key).snapshotChanges().pipe(map((action: any) => action))
}))
)
}),
map(([facData]) => {
return facData.map((item: any) => {
let obj: any = item.payload.toJSON();
return {
...obj,
'$id': item.key
};
});
})
)
}
debouncing
export class App {
items: Array<string>;
term = new FormControl();
constructor(private wikipediaService: WikipediaService) {
this.term.valueChanges
.debounceTime(400)
.subscribe(term => this.wikipediaService.search(term).then(items => this.items = items));
}
}toPromise() // use obserable to promise() // I used in serverless async and await in s3 sdkreturn this.jsonp
.get('http://en.wikipedia.org/w/api.php?callback=JSONP_CALLBACK', { search })
.toPromise()
.then((response) => response.json()[1]);
fromPromise() /// it use in obserable from promiseVVVI ( multiple time http call)
return new BehaviorSubject(null).pipe(
switchMap(size => this.ngFireDb.list(this.FBD.components(parent.facility), ref => ref.child(parent.component)).snapshotChanges()),
map((sn: any) => {
sn.map(item =>{
if(item.key == 'name'){
retString = item.payload.toJSON();
// console.log('name', item.payload.toJSON());
}
});
return retString;
}),
switchMap(retString => this.ngFireDb.list(this.FBD.devices(parent.facility), ref => ref.child(parent.device)).snapshotChanges()),
map((sn: any) => {
let devicename ='';
sn.map(item =>{
if(item.key == 'name'){
devicename = item.payload.toJSON();
}
});
return devicename+ ' - ' + retString;
})
);
No comments:
Post a Comment