@@ -10,7 +10,7 @@ const mb = engine.getPlugin('obsidian-meta-bind-plugin').api;
10
10
const comp = new obsidian.Component(component);
11
11
12
12
// create a bind target to the property that we care about
13
- const bindTarget = mb.bindTargetParser.fromStringAndValidate ('locked', context.file.path);
13
+ const bindTarget = mb.parseBindTarget ('locked', context.file.path);
14
14
15
15
// the render function, it takes the locked value as the argument
16
16
function render(value) {
@@ -34,10 +34,10 @@ function render(value) {
34
34
}
35
35
36
36
// we create a reactive component from the render function and the initial value will be the value of the bind target
37
- const reactive = engine.reactive(render, mb.getMetadataWithBindTarget (bindTarget));
37
+ const reactive = engine.reactive(render, mb.getMetadata (bindTarget));
38
38
39
39
// then we subscribe to the metadata that the bind target points to and rerender the reactive component everythime the bind target value changes
40
- const subscription = mb.subscribeToMetadataWithBindTarget (
40
+ const subscription = mb.subscribeToMetadata (
41
41
bindTarget,
42
42
(value) => reactive.refresh(value)
43
43
);
@@ -51,21 +51,20 @@ return reactive;
51
51
``` js-engine
52
52
const mb = engine.getPlugin('obsidian-meta-bind-plugin').api;
53
53
54
+ const bindTarget = mb.parseBindTarget('text', context.file.path);
55
+
54
56
function onUpdate(value) {
55
57
return value.toString();
56
58
}
57
59
58
- const reactive = engine.reactive(onUpdate, context.metadata.frontmatter.text );
60
+ const reactive = engine.reactive(onUpdate, mb.getMetadata(bindTarget) );
59
61
60
62
const subscription = mb.subscribeToMetadata(
61
- 'frontmatter',
62
- context.file.path,
63
- ['text'],
64
- false,
63
+ bindTarget,
65
64
(value) => reactive.refresh(value)
66
65
);
67
66
68
67
component.register(() => subscription.unsubscribe());
69
68
70
69
return reactive;
71
- ```
70
+ ```
0 commit comments