Skip to content

Commit 4c8ec1f

Browse files
committed
add Cerebral example
1 parent c7ad2b2 commit 4c8ec1f

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

quasar.conf.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = function (/* ctx */) {
1313
// --> boot files are part of "main.js"
1414
// https://quasar.dev/quasar-cli/cli-documentation/boot-files
1515
boot: [
16-
16+
'cerebral'
1717
],
1818

1919
// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css
@@ -64,7 +64,8 @@ module.exports = function (/* ctx */) {
6464

6565
// Full list of options: https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-build
6666
build: {
67-
vueRouterMode: 'hash', // available values: 'hash', 'history'
67+
vueRouterMode: 'history', // available values: 'hash', 'history'
68+
vueCompiler: true, // <- important to integrate Cerebral
6869

6970
// rtl: false, // https://quasar.dev/options/rtl-support
7071
// showProgress: false,
@@ -93,7 +94,7 @@ cfg.module.rules.push({
9394
devServer: {
9495
https: false,
9596
port: 8080,
96-
open: true // opens browser window automatically
97+
open: false // opens browser window automatically
9798
},
9899

99100
// animations: 'all', // --- includes all animations

src/boot/cerebral.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import {Container} from "@cerebral/vue";
2+
import Cerebral from "cerebral";
3+
import App from '../App.vue'
4+
5+
const Controller = Cerebral({
6+
state: {
7+
message: 'Welcome to Cerebral!',
8+
},
9+
});
10+
11+
export default async (context) => {
12+
let render = h =>
13+
h({
14+
components: {
15+
HOC: Container(Controller),
16+
App,
17+
},
18+
template: '<HOC><App/></HOC>',
19+
})
20+
context.app.render = render
21+
}

src/pages/Index.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
<img
44
alt="Quasar logo"
55
src="~assets/quasar-logo-full.svg"
6-
>
6+
/>
7+
<h1 class="bg-yellow-4">{{welcome}}</h1>
78
</q-page>
89
</template>
910

1011
<script>
11-
export default {
12-
name: 'PageIndex'
13-
}
12+
import {connect} from '@cerebral/vue'
13+
import {state} from 'cerebral'
14+
15+
export default connect({welcome: state`message`}, {
16+
name: 'PageIndex',
17+
})
1418
</script>

0 commit comments

Comments
 (0)