Hi Amar,

I assume your function needs to return an observable of type boolean?
Based on this assumption, this should do the trick:

function fileTemplateFilter() {
return Observable.create(observable => {
this.uploader.options.filters.push({
name: "fileTemplateFilter",
fn: (item, options) => {
var type = item.type || null;
if (type == "application/pdf") return of(true);
this.fileUploadLoader = true;
return Observable.forkJoin([
this.getCsvHeaders(item.name, 1),
this.getFileHeaders(item.rawFile)
]).pipe(
map(
([fileHeaders, tableHeaders]) =>
fileHeaders.length == tableHeaders.length &&
fileHeaders.every(function(element, index) {
return element === tableHeaders[index];
})
),
tap(isSame => {
// this is a side effect, and should not be here actually!
this.fileUploadLoader = !isSame;
})
);
}
});
});
}

There are still some issues left in there, mostly around error handling. 
You might want to add something that logs the state to the console. You can 
use tap for that.

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to