-
Notifications
You must be signed in to change notification settings - Fork 2
/
Container.html
36 lines (28 loc) · 999 Bytes
/
Container.html
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
<div ref:_container></div>
<script>
import { Tracker } from 'meteor/tracker';
export default {
oncreate() {
const { initialData, data, oncreate } = this._options;
this._instance = new this._component({
target: this.refs._container,
data: initialData && initialData.call()
});
// Create an empty context object that will be passed as `this` to each
// user-defined function. This object can be used to store container
// state, e.g., live query handles and timeout identifiers.
this._context = Object.create(null);
Tracker.nonreactive(() => {
this._computation = Tracker.autorun(() => {
data.call(this._context, this._instance);
});
});
oncreate && oncreate.call(this._context, this._instance);
},
ondestroy() {
const { ondestroy } = this._options;
this._computation.stop();
ondestroy && ondestroy.call(this._context, this._instance);
}
};
</script>