FFFF Added global process variable for plugins that rely on it. · will007008/nativescript-vue@a673cf7 · GitHub
[go: up one dir, main page]

Skip to content

Commit a673cf7

Browse files
committed
Added global process variable for pl 8000 ugins that rely on it.
Cleaned up sample applications. Added sample application with vuex
1 parent dd19d7b commit a673cf7

File tree

8 files changed

+52
-9
lines changed

8 files changed

+52
-9
lines changed

platform/nativescript/framework.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ console.keys = function(object) {
22
console.dir(Object.keys(object))
33
}
44

5+
// This is required because some of the third party plugins rely on this
6+
// and cause errors since there is no process variable in {N}.
7+
global.process = global.process || {}
8+
global.process.env = global.process.env || {}
9+
510
import Vue from './runtime/index'
611
import ModalPlugin from './modal-plugin'
712
import NavigatorPlugin from './navigator-plugin'

samples/app/app-with-list-view.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
const Vue = require('./nativescript-vue')
22
const http = require('http')
33
const Page = require('ui/page').Page
4-
const StackLayout = require('ui/layouts/stack-layout').StackLayout
5-
const ScrollView = require('ui/scroll-view').ScrollView
6-
const Image = require('ui/image').Image
7-
const Label = require('ui/label').Label
8-
const Button = require('ui/button').Button
94

105
Vue.prototype.$http = http
116
Vue.registerElement('gradient', () => require('nativescript-gradient').Gradient)

samples/app/app-with-router-pages.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const Vue = require('./nativescript-vue')
22
const VueRouter = require('vue-router')
33
Vue.use(VueRouter)
4-
global.process = { env: {} } // hack! a build process should replace process.env's with static strings.
54

65
const Foo = {
76
template: `

samples/app/app-with-router.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const Vue = require('./nativescript-vue')
22
const VueRouter = require('vue-router')
33
Vue.use(VueRouter)
4-
global.process = { env: {} } // hack! a build process should replace process.env's with static strings.
54

65
const Foo = {
76
template: `

samples/app/app-with-tabview-router.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const Vue = require('./nativescript-vue')
22
const VueRouter = require('vue-router')
33
Vue.use(VueRouter)
4-
global.process = { env: {} } // hack! a build process should replace process.env's with static strings.
54

65
const TabComponent = {
76
template: `

samples/app/app-with-vuex.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const Vue = require('./nativescript-vue')
2+
const Vuex = require('vuex')
3+
4+
Vue.use(Vuex)
5+
6+
const store = new Vuex.Store({
7+
state: {
8+
count: 42
9+
},
10+
11+
mutations: {
12+
decrement(state) {
13+
state.count--
14+
}
15+
}
16+
})
17+
18+
new Vue({
19+
store,
20+
template: `
21+
<Page>
22+
<Stack-Layout>
23+
<Label :text="count + ' taps left'" style="text-align: center; font-size: 30; padding: 20 0;"/>
24+
<Button text="Tap" @tap="decrement"/>
25+
</Stack-Layout>
26+
</Page>
27+
`,
28+
29+
computed: {
30+
count() {
31+
return this.$store.state.count
32+
}
33+
},
34+
35+
methods: {
36+
decrement() {
37+
this.$store.commit('decrement')
38+
}
39+
}
40+
}).$start()

samples/package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"nativescript-gradient": "^2.0.0",
1717
"nativescript-theme-core": "~1.0.2",
1818
"tns-core-modules": "^3.0.0",
19-
"vue-router": "^2.4.0"
19+
"vue-router": "^2.4.0",
20+
"vuex": "^3.0.0"
2021
},
2122
"devDependencies": {
2223
"babel-traverse": "6.24.1",

0 commit comments

Comments
 (0)
0