本文整理匯總了TypeScript中rxjs/observable/empty.empty函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript empty函數的具體用法?TypeScript empty怎麽用?TypeScript empty使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了empty函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: initWindowName
export function initWindowName(window: Window) {
const saved = (() => {
/**
* On page load, check window.name for an existing
* BS json blob & parse it.
*/
try {
return parseFromString(window.name);
} catch (e) {
return {};
}
})();
/**
* Remove any existing BS json from window.name
* to ensure we don't interfere with any other
* libs who may be using it.
*/
window.name = window.name.replace(regex, "");
/**
* If the JSON was parsed correctly, try to
* find a scroll property and restore it.
*/
if (saved && saved.bs && saved.bs.hardReload && saved.bs.scroll) {
const { x, y } = saved.bs.scroll;
return of<any>(
setScroll(x, y),
Log.consoleDebug(`[ScrollRestore] x = ${x} y = ${y}`)
);
}
return empty();
}
示例2: switchMap
switchMap(scroll => {
if (!scroll) return empty();
return fromEvent(document, "scroll", true).pipe(
map((e: Event) => e.target),
withLatestFrom(canSync$, elemMap$),
filter(([, canSync]) => Boolean(canSync)),
map(([target, canSync, elemMap]: [any, boolean, any[]]) => {
if (target === document) {
return ScrollEvent.outgoing(
getScrollPosition(window, document),
"document",
0
);
}
const elems = document.getElementsByTagName(target.tagName);
const index = Array.prototype.indexOf.call(
elems || [],
target
);
return ScrollEvent.outgoing(
getScrollPositionForElement(target),
target.tagName,
index,
elemMap.indexOf(target)
);
})
);
})
示例3: function
return function(data, options: ReloadOptions): Observable<any> {
const {path} = data;
if (options.liveCSS) {
if (path.match(/\.css$/i)) {
return reloadStylesheet(path, document, navigator);
}
}
if (options.liveImg) {
if (path.match(/\.(jpe?g|png|gif)$/i)) {
return reloadImages(path, document);
}
}
/**
* LEGACY
*/
const domData = getElems(data.ext, options, document);
const elems = getMatches(domData.elems, data.basename, domData.attr);
for (var i = 0, n = elems.length; i < n; i += 1) {
swapFile(elems[i], domData, options, document, navigator);
}
return empty();
}
示例4: sendEmailVerification
public sendEmailVerification() {
if (this.auth$.auth.currentUser) {
return Observable.fromPromise(
this.auth$.auth.currentUser.sendEmailVerification(),
);
} else {
return empty();
}
}
示例5: updatePassword
public updatePassword(password: string) {
if (this.auth$.auth.currentUser) {
return Observable.fromPromise(
this.auth$.auth.currentUser.updatePassword(password),
);
} else {
return empty();
}
}
示例6: mergeMap
mergeMap(([event, options]) => {
if (event.url || !options.injectChanges) {
return reloadBrowserSafe();
}
if (event.basename && event.ext && isBlacklisted(event)) {
return empty();
}
return of(fileReload(event));
})
示例7: reloadStylesheet
function reloadStylesheet(path: string, document: Document, navigator): Observable<any> {
// has to be a real array, because DOMNodeList will be modified
const links: HTMLLinkElement[] = array(document.getElementsByTagName('link'))
.filter(link => {
return link.rel.match(/^stylesheet$/i)
&& !link.__LiveReload_pendingRemoval;
});
/**
* Find imported style sheets in <style> tags
* @type {any[]}
*/
const styleImported = array(document.getElementsByTagName('style'))
.filter(style => Boolean(style.sheet))
.reduce((acc, style) => {
return acc.concat(collectImportedStylesheets(style, style.sheet));
}, []);
/**
* Find imported style sheets in <link> tags
* @type {any[]}
*/
const linksImported = links
.reduce((acc, link) => {
return acc.concat(collectImportedStylesheets(link, link.sheet));
}, []);
/**
* Combine all links + sheets
*/
const allRules = links.concat(styleImported, linksImported);
/**
* Which href best matches the incoming href?
*/
const match = pickBestMatch(path, allRules, l => pathFromUrl(linkHref(l)));
if (match) {
if (match.object && match.object.rule) {
return reattachImportedRule(match.object, document);
}
return reattachStylesheetLink(match.object, document, navigator);
} else {
if (links.length) {
// no <link> elements matched, so was the path including '*'?
const [first, ...rest] = path.split('.');
if (first === '*') {
return from(links.map(link => reattachStylesheetLink(link, document, navigator)))
.pipe(mergeAll())
}
}
}
return empty();
}
示例8: map
return folders.map(path => MyAppsPanelService.makeTreeNode({
id: path,
data: path,
type: "folder",
label: AppHelper.getBasename(path),
isExpanded: this.localExpandedNodes.pipe(
map(list => list.indexOf(path) !== -1)
),
children: empty().pipe(
concat(this.fileRepository.watch(path)),
map(listing => this.createDirectoryListingTreeNodes(listing))
)
}));
示例9: calc
calc(): Observable<any> {
const url = `https://maps.googleapis.com/maps/api/geocode/json?address=${this._formatAddress()}&key=${
this._apiKey
}`;
if (!this._address.street && !this._address.zip && !this._address.city) {
return empty();
}
return this._http.getRaw(url).pipe(
map((res: ServiceResults) => {
this._geoCodes = res.results[0].geometry.location;
return this._geoCodes || undefined;
})
);
}
示例10: fetchFileContent
fetchFileContent(almostID: string, parse = false): Observable<string> {
const source = DataGatewayService.getFileSource(almostID);
if (source === "local") {
const fetch = empty().pipe(concat(this.ipc.request("getLocalFileContent", almostID)));
if (parse) {
return fetch.pipe(
map(content => {
try {
return YAML.safeLoad(content, {json: true, onWarning: noop} as any);
} catch (err) {
return new Error(err);
}
})
);
}
return fetch;
}
if (source === "app" || source === "public") {
const fetch = empty().pipe(
concat(this.ipc.request("getPlatformApp", {id: almostID}))
);
if (parse) {
return fetch.pipe(
map(content => JSON.parse(content))
);
}
return fetch;
}
}