Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

fix(core): fix #969, should be able to access target/eventName info in onScheduleTask#972

Merged
mhevery merged 1 commit intoangular:masterfrom
JiaLiPassion:target
Dec 27, 2017
Merged

fix(core): fix #969, should be able to access target/eventName info in onScheduleTask#972
mhevery merged 1 commit intoangular:masterfrom
JiaLiPassion:target

Conversation

@JiaLiPassion
Copy link
Copy Markdown
Collaborator

fix #969.

Should be able to access target/eventName/capture information when using addEventListener in onScheduleTask callback.

in onScheduleTask.

   onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
                           task: Task): any => {
            const target = (task.data as any).taskData.target;
            const eventName = (task.data as any).taskData.eventName;
            const capture = (task.data as any).taskData.capture;
            return parentZoneDelegate.scheduleTask(targetZone, task);
    }

in onInvokeTask, onCancelTask.

onInvokeTask(
                 parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task,
                 applyThis: any, applyArgs: any) {
      const target = (task as any).target;
      const eventName = (task as any).eventName;
      const capture = (task as any).capture;
}

it is not consistent because of performance concern (don't want to create so many object).

Comment thread lib/common/events.ts Outdated
const data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : null;

// keep taskData into data to allow onScheduleEventTask to acess the task information
(data as any).taskData = taskData;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the useGlobalCallback is false, data would be null and this line would fail.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jahtalab, yes, you are right, thank you.

@hmdhk
Copy link
Copy Markdown
Contributor

hmdhk commented Dec 1, 2017

Is useGlobalCallback a configuration option? AFAICS it's always true.
I'm worried about if useGlobalCallback is false then the taskData would not be accessible.

@JiaLiPassion
Copy link
Copy Markdown
Collaborator Author

@jahtalab , it is configurable when you want to patch some new API, but for the built in patch, it is always true, and currently it will be false in nodejs environment and RTCPeerConnection patch.

@hmdhk
Copy link
Copy Markdown
Contributor

hmdhk commented Dec 1, 2017

Thanks @JiaLiPassion ,
Is there any timeline for the next release that could include this fix?

@JiaLiPassion
Copy link
Copy Markdown
Collaborator Author

@jahtalab, you are welcome and I am not sure the release date.

@hmdhk
Copy link
Copy Markdown
Contributor

hmdhk commented Dec 4, 2017

Tests are failing because of rxjs changes in exposed API in the newer versions. I had to lock rxjs version to 5.4.2 to make them pass.

@JiaLiPassion
Copy link
Copy Markdown
Collaborator Author

@jahtalab , yes, this is a known issue, the other PR has used the rxjs 5.5.3 will fix this issue.

@mhevery mhevery merged commit e58c8bb into angular:master Dec 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need a way to access target for eventTasks

4 participants