Skip to content

Remove the Dictionary class #855

Description

@tbouffard

The Dictionary class comes from the old mxGraph codebase and was introduced before ES6. Its main goal is to mimic what native JavaScript Map now provides:

class Dictionary<T extends IdentityObject | IdentityFunction | null, U> {

We should remove this class and replace its usage with Map.

Important

This class is currently part of the public API. For example, it’s used to access overlays on a CellState:

// Used by CellRenderer.createCellOverlays
overlays: Dictionary<CellOverlay, Shape> = new Dictionary();

The only extra feature provided by Dictionary is that remove(key) returns the removed element (if any).
In Map, this can be replaced by:

const value = map.get(key);
map.delete(key);
return value;

This usage is rare in the codebase and should be easy to migrate.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions