Skip to content
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

Ck/12077 mixins #12140

Merged
merged 8 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions packages/ckeditor5-utils/src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
* @module utils/collection
*/

import EmitterMixin, { type Emitter } from './emittermixin';
import { Emitter } from './emittermixin';
import CKEditorError from './ckeditorerror';
import uid from './uid';
import isIterable from './isiterable';
import mix from './mix';

/**
* Collections are ordered sets of objects. Items in the collection can be retrieved by their indexes
Expand All @@ -25,7 +24,7 @@ import mix from './mix';
*
* @mixes module:utils/emittermixin~EmitterMixin
*/
class Collection<T extends { [ id in I ]?: string }, I extends string = 'id'> implements Iterable<T> {
export default class Collection<T extends { [ id in I ]?: string }, I extends string = 'id'> extends Emitter implements Iterable<T> {
/**
* The internal list of items in the collection.
*
Expand Down Expand Up @@ -131,6 +130,8 @@ class Collection<T extends { [ id in I ]?: string }, I extends string = 'id'> im
* Items that do not have such a property will be assigned one when added to the collection.
*/
constructor( initialItemsOrOptions: Iterable<T> | { readonly idProperty?: I } = {}, options: { readonly idProperty?: I } = {} ) {
super();

const hasInitialItems = isIterable( initialItemsOrOptions );

if ( !hasInitialItems ) {
Expand Down Expand Up @@ -781,12 +782,6 @@ class Collection<T extends { [ id in I ]?: string }, I extends string = 'id'> im
*/
}

mix( Collection, EmitterMixin );

interface Collection<T, I> extends Emitter {}

export default Collection;

export type AddEvent<T = any> = {
name: 'add';
args: [ item: T, index: number ];
Expand Down
Loading