Skip to content

fix(drag-drop): remove circular dependencies #12554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Aug 6, 2018

Currently we've got the following circular dependencies in master, after the CdkDragDropRegistry got introduced:

drop.ts -> drag.ts -> drag-drop-registry.ts -> drop.ts
drag.ts -> drag-drop-registry.ts -> drag.ts
drop.ts -> drag-drop-registry.ts -> drop.ts

These changes rework the registry to avoid importing CdkDrag and CdkDrop, in order to break the circular references.

@crisbeto crisbeto added pr: merge safe target: patch This PR is targeted for the next patch release labels Aug 6, 2018
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 6, 2018
@crisbeto crisbeto force-pushed the drag-drop-circular-references branch from 78bc342 to a7276fd Compare August 6, 2018 19:53
@devversion
Copy link
Member

devversion commented Aug 6, 2018

Note: After this is merged, consider merging #12548

@devversion devversion mentioned this pull request Aug 6, 2018
* @docs-private
*/
@Injectable({providedIn: 'root'})
export class CdkDragDropRegistry implements OnDestroy {
export class CdkDragDropRegistry<I, C extends {id: string}> implements OnDestroy {
Copy link
Member

Choose a reason for hiding this comment

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

Now that the things being dragged and dropped are generic, just make the class DragDropRegistry? The general rule is that things only start with Cdk if they're a directive with the cdk- selector prefix, but I interpreted the class name before as "registry for CdkDrag and CdkDrop". Since they're generics now, I don't think we should have the prefix

* Service that keeps track of all the `CdkDrag` and `CdkDrop` instances, and
* manages global event listeners on the `document`.
* Service that keeps track of all the drag item and drop container
* instances, and manages global event listeners on the `document`.
Copy link
Member

Choose a reason for hiding this comment

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

It would be good to have a (non-public-facing) comment in this file somewhere that explains why this is genericized instead of using concrete types.

Currently we've got the following circular dependencies in master, after the `CdkDragDropRegistry` got introduced:

```
drop.ts -> drag.ts -> drag-drop-registry.ts -> drop.ts
drag.ts -> drag-drop-registry.ts -> drag.ts
drop.ts -> drag-drop-registry.ts -> drop.ts
```

These changes rework the registry to avoid importing `CdkDrag` and `CdkDrop`, in order to break the circular references.
@crisbeto crisbeto force-pushed the drag-drop-circular-references branch from a7276fd to 7667e3e Compare August 7, 2018 16:41
@crisbeto
Copy link
Member Author

crisbeto commented Aug 7, 2018

I've addressed the feedback @jelbourn.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Aug 7, 2018
@josephperrott josephperrott merged commit 9bd08e7 into angular:master Aug 8, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants