本文整理匯總了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);
}
示例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);
}
});
}
}
示例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());
}
示例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);
}
示例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());
}
示例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);
});
}
示例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);
});
}
}
示例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);
}
});
}
}
示例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();
}
});
}
示例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);
}
}