Skip to content

Commit 88dbdda

Browse files
committed
feat: add mountComponent and loadById helpers
1 parent 52bb0df commit 88dbdda

File tree

3 files changed

+21
-40
lines changed

3 files changed

+21
-40
lines changed

.gitignore

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
Skip to content
2-
3-
Search or jump to…
4-
5-
Pull requests
6-
Issues
7-
Marketplace
8-
Explore
9-
10-
@marconi1992
11-
9
12-
0
13-
2 0 marconi1992/hypernova-vue
14-
Code Issues 0 Pull requests 0 Projects 0 Wiki Security Insights Settings
15-
hypernova-vue/.gitignore
16-
@marconi1992 marconi1992 First steps
17-
ee91b83 on Feb 20
18-
34 lines (25 sloc) 502 Bytes
19-
201
# Logs
212
logs
223
*.log
@@ -51,17 +32,3 @@ lib
5132
npm-shrinkwrap.json
5233
yarn.lock
5334
package-lock.json
54-
© 2019 GitHub, Inc.
55-
Terms
56-
Privacy
57-
Security
58-
Status
59-
Help
60-
Contact GitHub
61-
Pricing
62-
API
63-
Training
64-
Blog
65-
About
66-
67-
example

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hypernova-svelte",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "Svelte Bindings for Hypernova",
55
"main": "lib/index.js",
66
"author": "Felipe Guizar Diaz <felipegaiacharly@gmail.com>",

src/index.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
import hypernova, { serialize, load } from 'hypernova';
22
import { findNode, getData } from 'nova-helpers';
33

4-
const mountComponent = (Component, node, data) => {
5-
return new Component({
6-
target: node,
7-
props: data,
8-
hydrate: true,
9-
});
4+
export { load } from 'hypernova';
5+
6+
export const loadById = (name, id) => {
7+
const node = findNode(name, id);
8+
const data = getData(name, id);
9+
10+
if (node && data) {
11+
return {
12+
node,
13+
data,
14+
};
15+
}
16+
17+
return null;
1018
};
1119

20+
export const mountComponent = (Component, node, data) => new Component({
21+
target: node,
22+
props: data,
23+
hydrate: true,
24+
});
25+
1226
export const renderInPlaceholder = (name, Component, id) => {
1327
const node = findNode(name, id);
1428
const data = getData(name, id);

0 commit comments

Comments
 (0)