forked from MapComplete/MapComplete
Various bug fixes, add layer selection and background selection as parameter to the URL (fix #86, fix #84)
This commit is contained in:
parent
e35c85fc55
commit
97a69ff903
14 changed files with 111 additions and 25 deletions
|
@ -45,9 +45,14 @@ export class UIEventSource<T>{
|
|||
}
|
||||
|
||||
public map<J>(f: ((T) => J),
|
||||
extraSources: UIEventSource<any>[] = []): UIEventSource<J> {
|
||||
extraSources: UIEventSource<any>[] = [],
|
||||
g: ((J) => T) = undefined ): UIEventSource<J> {
|
||||
const self = this;
|
||||
|
||||
|
||||
const newSource = new UIEventSource<J>(
|
||||
f(this.data)
|
||||
);
|
||||
|
||||
const update = function () {
|
||||
newSource.setData(f(self.data));
|
||||
newSource.ping();
|
||||
|
@ -57,9 +62,12 @@ export class UIEventSource<T>{
|
|||
for (const extraSource of extraSources) {
|
||||
extraSource.addCallback(update);
|
||||
}
|
||||
const newSource = new UIEventSource<J>(
|
||||
f(this.data)
|
||||
);
|
||||
|
||||
if(g !== undefined) {
|
||||
newSource.addCallback((latest) => {
|
||||
self.setData((g(latest)));
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return newSource;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue