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

TypeScript events.CoreEventsProvider类代码示例

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

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



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

示例1: constructor

    constructor(platform: Platform, pushNotificationsProvider: AddonPushNotificationsProvider, eventsProvider: CoreEventsProvider,
            localNotificationsProvider: CoreLocalNotificationsProvider, loggerProvider: CoreLoggerProvider,
            updateManager: CoreUpdateManagerProvider, cronDelegate: CoreCronDelegate,
            registerCronHandler: AddonPushNotificationsRegisterCronHandler,
            unregisterCronHandler: AddonPushNotificationsUnregisterCronHandler) {

        const logger = loggerProvider.getInstance('AddonPushNotificationsModule');

        // Register the handlers.
        cronDelegate.register(registerCronHandler);
        cronDelegate.register(unregisterCronHandler);

        // Register device on GCM or APNS server.
        platform.ready().then(() => {
            pushNotificationsProvider.registerDevice();
        });

        eventsProvider.on(CoreEventsProvider.NOTIFICATION_SOUND_CHANGED, () => {
            // Notification sound has changed, register the device again to update the sound setting.
            pushNotificationsProvider.registerDevice();
        });

        // Register device on Moodle site when login.
        eventsProvider.on(CoreEventsProvider.LOGIN, () => {
            pushNotificationsProvider.registerDeviceOnMoodle().catch((error) => {
                logger.warn('Can\'t register device', error);
            });
        });

        eventsProvider.on(CoreEventsProvider.SITE_DELETED, (site) => {
            pushNotificationsProvider.unregisterDeviceOnMoodle(site).catch((error) => {
                logger.warn('Can\'t unregister device', error);
            });
            pushNotificationsProvider.cleanSiteCounters(site.id);
        });

        // Listen for local notification clicks (generated by the app).
        localNotificationsProvider.registerClick(AddonPushNotificationsProvider.COMPONENT,
            pushNotificationsProvider.notificationClicked.bind(pushNotificationsProvider));

        // Allow migrating the table from the old app to the new schema.
        updateManager.registerAppTableMigration({
            name: 'mma_pushnotifications_badge',
            newName: AddonPushNotificationsProvider.BADGE_TABLE,
            fields: [
                {
                    name: 'siteid',
                    newName: 'siteId'
                }
            ]
        });

        // Migrate the component name.
        updateManager.registerLocalNotifComponentMigration('mmaPushNotifications', AddonPushNotificationsProvider.COMPONENT);
    }
开发者ID:santosleonardo,项目名称:moodlemobile2,代码行数:55,代码来源:pushnotifications.module.ts


示例2: constructor

    constructor(platform: Platform, delegate: CoreFileUploaderDelegate, handler: CoreSharedFilesUploadHandler,
            helper: CoreSharedFilesHelperProvider, eventsProvider: CoreEventsProvider) {
        // Register the handler.
        delegate.registerHandler(handler);

        if (platform.is('ios')) {
            let lastCheck = 0;

            // Check if there are new files at app start and when the app is resumed.
            helper.searchIOSNewSharedFiles();
            platform.resume.subscribe(() => {
                // Wait a bit to make sure that APP_LAUNCHED_URL is treated before this callback.
                setTimeout(() => {
                    if (Date.now() - lastCheck < 1000) {
                        // Last check less than 1s ago, don't do anything.
                        return;
                    }

                    lastCheck = Date.now();
                    helper.searchIOSNewSharedFiles();
                }, 200);
            });

            eventsProvider.on(CoreEventsProvider.APP_LAUNCHED_URL, (url) => {
                if (url && url.indexOf('file://') === 0) {
                    // We received a file in iOS, it's probably a shared file. Treat it.
                    lastCheck = Date.now();
                    helper.searchIOSNewSharedFiles(url);
                }
            });
        }
    }
开发者ID:santosleonardo,项目名称:moodlemobile2,代码行数:32,代码来源:sharedfiles.module.ts


示例3: constructor

    constructor(userDelegate: CoreUserDelegate, userProfileMailHandler: CoreUserProfileMailHandler,
            eventsProvider: CoreEventsProvider, sitesProvider: CoreSitesProvider, userProvider: CoreUserProvider,
            contentLinksDelegate: CoreContentLinksDelegate, userLinkHandler: CoreUserProfileLinkHandler,
            courseOptionHandler: CoreUserParticipantsCourseOptionHandler, linkHandler: CoreUserParticipantsLinkHandler,
            courseOptionsDelegate: CoreCourseOptionsDelegate) {

        userDelegate.registerHandler(userProfileMailHandler);
        courseOptionsDelegate.registerHandler(courseOptionHandler);
        contentLinksDelegate.registerHandler(userLinkHandler);
        contentLinksDelegate.registerHandler(linkHandler);

        eventsProvider.on(CoreEventsProvider.USER_DELETED, (data) => {
            // Search for userid in params.
            const params = data.params;
            let userId = 0;

            if (params.userid) {
                userId = params.userid;
            } else if (params.userids) {
                userId = params.userids[0];
            } else if (params.field === 'id' && params.values && params.values.length) {
                userId = params.values[0];
            } else if (params.userlist && params.userlist.length) {
                userId = params.userlist[0].userid;
            }

            if (userId > 0) {
                userProvider.deleteStoredUser(userId, data.siteId);
            }
        }, sitesProvider.getCurrentSiteId());
    }
开发者ID:SATS-Seminary,项目名称:moodlemobile2,代码行数:31,代码来源:user.module.ts


示例4: constructor

    constructor(eventsProvider: CoreEventsProvider, sitesProvider: CoreSitesProvider) {

        this.siteId = sitesProvider.getCurrentSiteId();

        // Update split view or navigate.
        this.loadSplitViewObserver = eventsProvider.on(AddonMessagesProvider.SPLIT_VIEW_LOAD_EVENT, (data) => {
            if (data.discussion && (this.splitviewCtrl.isOn() || !data.onlyWithSplitView)) {
                this.gotoDiscussion(data.discussion, data.message);
            }
        }, this.siteId);
    }
开发者ID:SATS-Seminary,项目名称:moodlemobile2,代码行数:11,代码来源:index.ts


示例5: constructor

    constructor(mainMenuDelegate: CoreMainMenuDelegate, gradesMenuHandler: CoreGradesMainMenuHandler,
            courseOptionHandler: CoreGradesCourseOptionHandler, courseOptionsDelegate: CoreCourseOptionsDelegate,
            contentLinksDelegate: CoreContentLinksDelegate, userLinkHandler: CoreGradesUserLinkHandler,
            overviewLinkHandler: CoreGradesOverviewLinkHandler, userHandler: CoreGradesUserHandler,
            userDelegate: CoreUserDelegate, eventsProvider: CoreEventsProvider, sitesProvider: CoreSitesProvider) {

        // Register handlers.
        mainMenuDelegate.registerHandler(gradesMenuHandler);
        courseOptionsDelegate.registerHandler(courseOptionHandler);
        contentLinksDelegate.registerHandler(userLinkHandler);
        contentLinksDelegate.registerHandler(overviewLinkHandler);
        userDelegate.registerHandler(userHandler);

        // Clear user profile handler cache.
        eventsProvider.on(CoreUserProvider.PROFILE_REFRESHED, (data) => {
            userHandler.clearViewGradesCache(data.courseId, data.userId);
        }, sitesProvider.getCurrentSiteId());

        eventsProvider.on(CoreEventsProvider.LOGOUT, () => {
            userHandler.clearViewGradesCache();
        }, sitesProvider.getCurrentSiteId());
    }
开发者ID:SATS-Seminary,项目名称:moodlemobile2,代码行数:22,代码来源:grades.module.ts


示例6: constructor

    constructor(cronDelegate: CoreCronDelegate, syncHandler: CoreCourseSyncCronHandler, logHandler: CoreCourseLogCronHandler,
        platform: Platform, eventsProvider: CoreEventsProvider) {
        cronDelegate.register(syncHandler);
        cronDelegate.register(logHandler);

        platform.resume.subscribe(() => {
            // Log the app is open to keep user in online status.
            setTimeout(() => {
                cronDelegate.forceCronHandlerExecution(logHandler.name);
            }, 1000);
        });

        eventsProvider.on(CoreEventsProvider.LOGIN, () => {
            // Log the app is open to keep user in online status.
            setTimeout(() => {
                cronDelegate.forceCronHandlerExecution(logHandler.name);
            }, 1000);
        });
    }
开发者ID:SATS-Seminary,项目名称:moodlemobile2,代码行数:19,代码来源:course.module.ts


示例7: setStatusListener

    /**
     * Watch for changes on the status.
     */
    protected setStatusListener(): void {
        if (typeof this.statusObserver == 'undefined') {
            // Listen for changes on this module status.
            this.statusObserver = this.eventsProvider.on(CoreEventsProvider.PACKAGE_STATUS_CHANGED, (data) => {
                if (data.componentId === this.module.id && data.component === this.component) {
                    // The status has changed, update it.
                    const previousStatus = this.currentStatus;
                    this.currentStatus = data.status;

                    this.showStatus(this.currentStatus, previousStatus);
                }
            }, this.siteId);

            // Also, get the current status.
            this.modulePrefetchDelegate.getModuleStatus(this.module, this.courseId).then((status) => {
                this.currentStatus = status;
                this.showStatus(status);
            });
        }
    }
开发者ID:SATS-Seminary,项目名称:moodlemobile2,代码行数:23,代码来源:main-activity-component.ts


示例8: constructor

    constructor(platform: Platform, delegate: CoreFileUploaderDelegate, handler: CoreSharedFilesUploadHandler,
            helper: CoreSharedFilesHelperProvider, eventsProvider: CoreEventsProvider) {
        // Register the handler.
        delegate.registerHandler(handler);

        if (platform.is('ios')) {
            // Check if there are new files at app start and when the app is resumed.
            helper.searchIOSNewSharedFiles();
            platform.resume.subscribe(() => {
                helper.searchIOSNewSharedFiles();
            });

            eventsProvider.on(CoreEventsProvider.APP_LAUNCHED_URL, (url) => {
                if (url && url.indexOf('file://') === 0) {
                    // We received a file in iOS, it's probably a shared file. Treat it.
                    helper.searchIOSNewSharedFiles(url);
                }
            });
        }
    }
开发者ID:SATS-Seminary,项目名称:moodlemobile2,代码行数:20,代码来源:sharedfiles.module.ts


示例9: constructor

    constructor(initDelegate: CoreInitDelegate, remoteThemesProvider: AddonRemoteThemesProvider, eventsProvider: CoreEventsProvider,
            sitesProvider: CoreSitesProvider, loggerProvider: CoreLoggerProvider) {

        const logger = loggerProvider.getInstance('AddonRemoteThemesModule');

        // Preload the current site styles.
        initDelegate.registerProcess({
            name: 'AddonRemoteThemesPreloadCurrent',
            priority: CoreInitDelegate.MAX_RECOMMENDED_PRIORITY + 250,
            blocking: true,
            load: remoteThemesProvider.preloadCurrentSite.bind(remoteThemesProvider)
        });

        // Preload the styles of the rest of sites.
        initDelegate.registerProcess({
            name: 'AddonRemoteThemesPreload',
            blocking: true,
            load: remoteThemesProvider.preloadSites.bind(remoteThemesProvider)
        });

        let addingSite;

        // When a new site is added to the app, add its styles.
        eventsProvider.on(CoreEventsProvider.SITE_ADDED, (data) => {
            addingSite = data.siteId;

            remoteThemesProvider.addSite(data.siteId).catch((error) => {
                logger.error('Error adding site', error);
            }).then(() => {
                if (addingSite == data.siteId) {
                    addingSite = false;
                }

                // User has logged in, remove tmp styles and enable loaded styles.
                if (data.siteId == sitesProvider.getCurrentSiteId()) {
                    remoteThemesProvider.unloadTmpStyles();
                    remoteThemesProvider.enable(data.siteId);
                }
            });
        });

        // Update styles when current site is updated.
        eventsProvider.on(CoreEventsProvider.SITE_UPDATED, (data) => {
            if (data.siteId === sitesProvider.getCurrentSiteId()) {
                remoteThemesProvider.load(data.siteId).catch((error) => {
                    logger.error('Error loading site after site update', error);
                });
            }
        });

        // Enable styles of current site on login.
        eventsProvider.on(CoreEventsProvider.LOGIN, (data) => {
            remoteThemesProvider.unloadTmpStyles();
            remoteThemesProvider.enable(data.siteId);
        });

        // Disable added styles on logout.
        eventsProvider.on(CoreEventsProvider.LOGOUT, (data) => {
            remoteThemesProvider.clear();
        });

        // Remove site styles when a site is deleted.
        eventsProvider.on(CoreEventsProvider.SITE_DELETED, (site) => {
            remoteThemesProvider.removeSite(site.id);
        });

        // Load temporary styles when site config is checked in login.
        eventsProvider.on(CoreEventsProvider.LOGIN_SITE_CHECKED, (data) => {
            remoteThemesProvider.loadTmpStyles(data.config.mobilecssurl).catch((error) => {
                logger.error('Error loading tmp styles', error);
            });
        });

        // Unload temporary styles when site config is "unchecked" in login.
        eventsProvider.on(CoreEventsProvider.LOGIN_SITE_UNCHECKED, (data) => {
            if (data.siteId && data.siteId === addingSite) {
                // The tmp styles are from a site that is being added permanently.
                // Wait for the final site styles to be loaded before removing the tmp styles so there is no blink effect.
            } else {
                // The tmp styles are from a site that wasn't added in the end. Just remove them.
                remoteThemesProvider.unloadTmpStyles();
            }
        });
    }
开发者ID:SATS-Seminary,项目名称:moodlemobile2,代码行数:84,代码来源:remotethemes.module.ts


示例10: ngOnInit

    /**
     * Component being initialized.
     */
    ngOnInit(): void {
        super.ngOnInit();

        this.hasOffline = false;
        this.syncIcon = 'spinner';
        this.siteId = this.sitesProvider.getCurrentSiteId();
        this.moduleName = this.courseProvider.translateModuleName(this.moduleName);

        if (this.syncEventName) {
            // Refresh data if this discussion is synchronized automatically.
            this.syncObserver = this.eventsProvider.on(this.syncEventName, (data) => {
                this.autoSyncEventReceived(data);
            }, this.siteId);
        }
    }
开发者ID:SATS-Seminary,项目名称:moodlemobile2,代码行数:18,代码来源:main-activity-component.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript file.CoreFileProvider类代码示例发布时间:2022-05-28
下一篇:
TypeScript cron.CoreCronDelegate类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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