-
Notifications
You must be signed in to change notification settings - Fork 7
/
reactive.ts
43 lines (40 loc) · 1 KB
/
reactive.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* egjs-conveyer
* Copyright (c) 2022-present NAVER Corp.
* MIT license
*/
import Conveyer from "./Conveyer";
import { CONVEYER_EVENTS, CONVEYER_METHODS } from "./consts";
import { ReactiveAdapter, Ref } from "@cfcs/core";
import { ConveyerEvents, ConveyerMethods, ConveyerOptions, ConveyerReactiveState } from "./types";
export interface ConveyerData {
container: Ref<HTMLElement>;
props: ConveyerOptions;
}
export const REACTIVE_CONVEYER: ReactiveAdapter<
Conveyer,
ConveyerReactiveState,
keyof ConveyerMethods,
ConveyerData,
ConveyerEvents
> = {
methods: CONVEYER_METHODS,
events: CONVEYER_EVENTS,
created(data) {
return new Conveyer(data.container, { ...data.props, autoInit: false });
},
init(instance, data) {
if (data.props.autoInit !== false) {
instance.init();
}
},
on(instance, name, callback) {
instance.on(name, callback);
},
off(instance, name, callback) {
instance.off(name, callback);
},
destroy(instance) {
instance.destroy();
},
};