antvis/G6

Change the plugin registration method #5318

Aarebecca posted onGitHub

In current, we register plugins with following method:

import { Graph, Extensions, extend } from '@antv/g6';

const ExtGraph = extend(Graph, {
  // ...
});

const graph = new Graph({ ... });

This is all about supporting better typescript type hints, but the actual effect is not ideal and the coding style is not elegant enough.

For these reasons, we decided to go back to a plugin registration mechanism similar to the v4 version, for an example, G6 will exports registerPlugin function

import { registerPlugin, Extensions } from '@antv/g6';

registerPlugin('node', {
  name: 'custom-node',
  plugin: Extensions.CustomNode
});

type problem:

  1. We will add all built-in plugin types into the specification definition, regardless of whether the plugin is properly registered
  2. For third-party custom plugins, the type problem is resolved by passing in the stereotype type

Fund this Issue

$0.00
Funded

Pull requests