• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript fromEvent.fromEvent函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中rxjs/observable/fromEvent.fromEvent函数的典型用法代码示例。如果您正苦于以下问题:TypeScript fromEvent函数的具体用法?TypeScript fromEvent怎么用?TypeScript fromEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了fromEvent函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: constructor

 constructor(private sanitizer: DomSanitizer, private orientation: ScreenOrientation) {
   this.fullscreen = merge(
     fromEvent(document, 'fullscreenchange'),
     fromEvent(document, 'webkitfullscreenchange'),
     fromEvent(document, 'mozfullscreenchange'),
   );
 }
开发者ID:ifiske,项目名称:iFiske,代码行数:7,代码来源:youtube.ts


示例2: dragOver

    private dragOver() {
        const dragEnter = fromEvent(this.el, this.domEvents.ON_DRAG_ENTER_EVENT);
        const dragLeave = fromEvent(this.el, this.domEvents.ON_DRAG_LEAVE_EVENT);

        return dragEnter.pipe(
            flatMap(mouseDrag => of(mouseDrag).pipe(
                delay(500),
                takeUntil(dragLeave)
            ))
        );
    }
开发者ID:hmenager,项目名称:composer,代码行数:11,代码来源:drag-over.directive.ts


示例3: 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)
                    );
                })
            );
        })
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:30,代码来源:scroll.listener.ts


示例4: hookToButtonKeyPressAndSubscribeToEvents

  hookToButtonKeyPressAndSubscribeToEvents() {
    const inputElement = document.getElementById('inputstuff');
    const keyPress$ = fromEvent<ElementRef>(inputElement, 'keypress')
      .pipe(delay(500));

    keyPress$.subscribe(
      (keypressevent: any) => {
        this.inputdata = (this.inputdata ? this.inputdata : '') + keypressevent.key;
      }
    );
  }
开发者ID:mewing200,项目名称:KenticoAngularJS,代码行数:11,代码来源:keystroke.component.ts


示例5: showAt

    showAt(container: ViewContainerRef, menuItems: MenuItem[], coordinates: { x: number, y: number }) {
        this.close();
        const factory = this.resolver.resolveComponentFactory(MenuComponent);
        this.embeddedComponent = container.createComponent<MenuComponent>(factory);
        this.embeddedComponent.instance.setItems(menuItems);

        const nEl = this.embeddedComponent.location.nativeElement as HTMLElement;

        const {x, y} = coordinates;
        nEl.style.position = "fixed";
        nEl.style.left = x + "px";
        nEl.style.top = y + "px";

        fromEvent(nEl, "contextmenu").subscribe((ev: MouseEvent) => {
            ev.stopPropagation();
        });

        fromEvent(document, "click").pipe(
            take(1)
        ).subscribe(() => {
            this.close();
        });
    }
开发者ID:hmenager,项目名称:composer,代码行数:23,代码来源:context.service.ts


示例6: switchMap

        switchMap(canToggle => {
            if (!canToggle) {
                return empty();
            }
            return fromEvent(document, "change", true).pipe(
                map((e: Event) => e.target || e.srcElement),
                filter((elem: HTMLInputElement) => elem.tagName === "SELECT"),
                withLatestFrom(canSync$),
                filter(([, canSync]) => canSync),
                map(([elem, canSync]: [HTMLInputElement, boolean]) => {
                    const data = getElementData(elem);

                    return FormToggleEvent.outgoing(data, {
                        type: elem.type,
                        checked: elem.checked,
                        value: elem.value
                    });
                })
            );
        })
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:20,代码来源:form-toggles.listener.ts


示例7: switchMap

        switchMap(formInputs => {
            if (!formInputs) {
                return empty();
            }
            return fromEvent(document.body, "keyup", true).pipe(
                map((e: Event) => e.target || e.srcElement),
                filter(
                    (target: Element) =>
                        target.tagName === "INPUT" ||
                        target.tagName === "TEXTAREA"
                ),
                withLatestFrom(canSync$),
                filter(([, canSync]) => canSync),
                map(([eventTarget]) => {
                    const target = getElementData(eventTarget);
                    const value = eventTarget.value;

                    return KeyupEvent.outgoing(target, value);
                })
            );
        })
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:21,代码来源:form-inputs.listener.ts


示例8: switchMap

 switchMap(canClick => {
     if (!canClick) {
         return empty();
     }
     return fromEvent(document, "click", true).pipe(
         map((e: Event) => e.target),
         filter((target: any) => {
             if (target.tagName === "LABEL") {
                 const id = target.getAttribute("for");
                 if (id && document.getElementById(id)) {
                     return false;
                 }
             }
             return true;
         }),
         withLatestFrom(canSync$),
         filter(([, canSync]) => canSync),
         map(([target]): OutgoingSocketEvent => {
             return ClickEvent.outgoing(getElementData(target));
         })
     );
 })
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:22,代码来源:clicks.listener.ts


示例9: fromEvent

 this._change = platform.isBrowser ? ngZone.runOutsideAngular(() => {
   return merge<Event>(fromEvent(window, 'resize'), fromEvent(window, 'orientationchange'));
 }) : observableOf();
开发者ID:GuzmanPI,项目名称:material2,代码行数:3,代码来源:viewport-ruler.ts


示例10: fromEvent

import { fromEvent } from 'rxjs/observable/fromEvent';
import { ajax } from 'rxjs/observable/dom/ajax';
import { map, filter, debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators';

const searchBox = document.getElementById('search-box');

const typeahead = fromEvent(searchBox, 'input').pipe(
  map((e: KeyboardEvent) => e.target.value),
  filter(text => text.length > 2),
  debounceTime(10),
  distinctUntilChanged(),
  switchMap(() => ajax('/api/endpoint'))
);

typeahead.subscribe(data => {
 // Handle the data from the API
});
开发者ID:cironunes,项目名称:angular,代码行数:17,代码来源:typeahead.ts



注:本文中的rxjs/observable/fromEvent.fromEvent函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript fromIterable.fromIterable函数代码示例发布时间:2022-05-25
下一篇:
TypeScript from.FromObservable类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap