本文整理汇总了TypeScript中camelot-unchained.events.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript events.on方法的具体用法?TypeScript events.on怎么用?TypeScript events.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类camelot-unchained.events
的用法示例。
在下文中一共展示了events.on方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: return
return (dispatch: (action: any) => any) => {
dispatch(init());
// Update avatar
client.OnEnemyTargetGenderChanged((gender: Gender) =>
client.OnEnemyTargetRaceChanged((race: Race) => {
dispatch(onAvatarChanged(getAvatar(gender, race)));
}),
);
client.OnEnemyTargetRaceChanged((race: Race) =>
client.OnEnemyTargetGenderChanged((gender: Gender) => {
dispatch(onAvatarChanged(getAvatar(gender, race)));
}),
);
client.OnCharacterPositionChanged(_.throttle((x: number, y: number) =>
dispatch(onCharacterPositionChanged({ x, y })), 250));
client.OnEnemyTargetPositionChanged(_.throttle((x: number, y: number) =>
dispatch(onTargetPositionChanged({ x, y })), 250));
// init handlers / events
events.on(events.clientEventTopics.handlesEnemyTarget, (player: Player) => dispatch(onCharacterUpdate(player)));
};
示例2: return
return (dispatch: (action: any) => any) => {
dispatch(init());
window.onresize = () => {
if (window.innerWidth >= 640 && window.innerHeight >= 480) {
// dispatch(resize());
}
};
// hook up to event triggers
events.on('hudnav--navigate', (name: string) => {
switch (name) {
case 'chat':
case 'crafting':
return dispatch(toggleVisibility(name));
case 'ui': return dispatch(toggleHUDLock());
case 'reset': return dispatch(resetHUD());
default: return;
}
});
window.window.addEventListener('keydown', (e: KeyboardEvent) => {
if (e.which === 27) {
dispatch(lockHUD());
}
});
};
示例3: return
return (dispatch: (action: any) => any) => {
dispatch(init());
if (!hasClientAPI()) return;
// init handlers / events
events.on(events.clientEventTopics.handlesEnemyTarget, (player: Player) => dispatch(characterUpdate(player)));
};
示例4: registerWarbandEvents
function registerWarbandEvents(dispatch: (action: WarbandAction) => any) {
events.on(signalr.WARBAND_EVENTS_JOINED, (info: {id: string, name: string}) => dispatch(warbandJoined(info.id, info.name)));
events.on(signalr.WARBAND_EVENTS_UPDATE, (info: {id: string, name: string}) => dispatch(warbandJoined(info.id, info.name)));
events.on(signalr.WARBAND_EVENTS_QUIT, () => dispatch(warbandQuit()));
events.on(signalr.WARBAND_EVENTS_ABANDONED, () => dispatch(warbandAbandoned()));
events.on(signalr.WARBAND_EVENTS_MEMBERJOINED, (member: WarbandMember) => dispatch(memberJoined(member)));
events.on(signalr.WARBAND_EVENTS_MEMBERUPDATE, (member: WarbandMember) => dispatch(memberUpdate(member)));
events.on(signalr.WARBAND_EVENTS_MEMBERREMOVED, (member: WarbandMember) => dispatch(memberRemoved(member)));
}
示例5: registerPatcherHubEvents
// HELPER METHODS
function registerPatcherHubEvents(dispatch: (action: ControllerAction) => any) {
events.on(signalr.PATCHER_EVENTS_ALERT, (alertJSON: string) => {
const alert = utils.tryParseJSON<webAPI.PatcherAlert>(alertJSON, client.debug);
if (alert !== null) dispatch(alertReceived(alert));
});
events.on(signalr.PATCHER_EVENTS_SERVERUPDATED, (serverJSON: string) => {
const server = utils.tryParseJSON<webAPI.ServerModel>(serverJSON, client.debug);
if (server !== null) dispatch(serverUpdate(server));
});
events.on(signalr.PATCHER_EVENTS_SERVERUNAVAILABLE, (name: string) => dispatch(serverUnavailable(name)));
events.on(signalr.PATCHER_EVENTS_CHARACTERUPDATED, (characterJSON: string) => {
const character = utils.tryParseJSON<webAPI.SimpleCharacter>(characterJSON, client.debug);
if (character !== null) dispatch(characterUpdate(character));
});
events.on(signalr.PATCHER_EVENTS_CHARACTERREMOVED, (id: string) => dispatch(characterRemoved(id)));
}
示例6: return
return (dispatch: (action: any) => any) => {
dispatch(init());
if (!hasClientAPI()) return;
// init handlers / events
client.OnCharacterStaminaChanged((current: number, max: number) => dispatch(staminaChanged(current, max)));
client.OnCharacterHealthChanged((current: number, max: number) => dispatch(healthChanged(current, max, BodyParts.Torso)));
client.OnCharacterNameChanged((name: string) => dispatch(nameChanged(name)));
client.OnCharacterRaceChanged((race: race) => dispatch(raceChanged(race)));
client.OnCharacterFactionChanged((faction: faction) => dispatch(factionChanged(faction)));
events.on(events.clientEventTopics.handlesCharacter, (player: Player) => dispatch(characterUpdate(player)));
};
示例7: return
return (dispatch: (action: any) => any) => {
dispatch(init());
// init handlers / events
client.OnCharacterStaminaChanged((current: number, max: number) => dispatch(onStaminaChanged(current, max)));
client.OnCharacterHealthChanged((current: number, max: number) =>
dispatch(onHealthChanged(current, max, BodyParts.Torso)));
client.OnCharacterInjuriesChanged((part: number, health: number, maxHealth: number) =>
dispatch(onHealthChanged(health, maxHealth, part)));
client.OnCharacterNameChanged((name: string) => dispatch(onNameChanged(name)));
client.OnCharacterFactionChanged((faction: Faction) => dispatch(onFactionChanged(faction)));
client.OnCharacterRaceChanged((race: Race) => {
dispatch(onRaceChanged(race));
client.OnCharacterGenderChanged((gender: Gender) => dispatch(onAvatarChanged(getAvatar(gender, race))));
});
events.on(events.clientEventTopics.handlesCharacter, (player: Player) => dispatch(onCharacterUpdate(player)));
};
示例8: registerInviteEvents
function registerInviteEvents(dispatch: (action: InvitesAction) => any) {
events.on(signalr.GROUP_EVENTS_INVITE_RECEIVED, (invite: GroupInvite) => dispatch(inviteReceived(invite)));
}