Lazy $apollo
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-apollo",
|
||||
"version": "1.0.0-beta11",
|
||||
"version": "1.0.0-beta.12",
|
||||
"description": "Vue apollo integration",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
+11
-3
@@ -159,7 +159,15 @@ class DollarApollo {
|
||||
function prepare() {
|
||||
this._apolloSubscriptions = [];
|
||||
|
||||
this.$apollo = new DollarApollo(this);
|
||||
// Lazy creation
|
||||
Object.defineProperty(this, '$apollo', {
|
||||
get: () => {
|
||||
if(!this._apollo) {
|
||||
this._apollo = new DollarApollo(this);
|
||||
}
|
||||
return this._apollo;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function launch() {
|
||||
@@ -201,8 +209,8 @@ module.exports = {
|
||||
sub.unsubscribe();
|
||||
});
|
||||
this._apolloSubscriptions = null;
|
||||
if (this.$apollo) {
|
||||
this.$apollo = null;
|
||||
if (this._apollo) {
|
||||
this._apollo = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user