Skip to content

Commit 7c8c128

Browse files
authored
Merge pull request #1 from saraedum/master
use @AsyncComputed decorator
2 parents 5b0305a + 0888e9a commit 7c8c128

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"detector-webgl": "^2.0.0",
1414
"three": "^0.104.0",
1515
"vue": "^2.6.10",
16-
"vue-async-computed": "^3.6.1",
16+
"vue-async-computed": "https://github.com/saraedum/vue-async-computed.git#5debb7dcd81f52183be55e05b866fc43278a990",
1717
"vue-class-component": "^7.1.0",
1818
"vue-color": "^2.7.0",
1919
"vue-gl": "^0.12.2",

src/components/OrbitControls.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414
@Prop() public readonly camera!: Camera;
1515
1616
public get cmr() {
17-
// @ts-ignore
1817
return this.vglNamespace.cameras[this.camera];
1918
}
2019
2120
@Watch('cmr', { immediate: true })
2221
public handler(cmr: Camera) {
2322
const controls = new OrbitControls(cmr);
24-
// @ts-ignore
2523
controls.addEventListener('change', () => this.vglNamespace.update());
2624
}
2725
}

src/components/WebglContainer.vue

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,30 @@
7878
</template>
7979

8080
<script lang="ts">
81-
// @ts-ignore
82-
import AsyncComputed from 'vue-async-computed';
81+
import VueAsyncComputed, { IAsyncComputedProperty } from 'vue-async-computed';
8382
import { Component, Prop, Vue } from 'vue-property-decorator';
8483
import { Material, Slider } from 'vue-color';
8584
import { BufferGeometry, LoadingManager, Vector3 } from 'three';
86-
// @ts-ignore
8785
import { STLLoader } from 'three/examples/jsm/loaders/STLLoader';
86+
import { createDecorator, VueDecorator } from 'vue-class-component';
8887
8988
import OrbitControls from './OrbitControls.vue';
9089
91-
Vue.use(AsyncComputed);
90+
Vue.use(VueAsyncComputed);
91+
92+
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
93+
94+
function AsyncComputed<T>(computedOptions?: Omit<IAsyncComputedProperty<T>, 'get'>): VueDecorator {
95+
return createDecorator((options, key) => {
96+
options.asyncComputed = options.asyncComputed || {};
97+
const method = options.methods![key];
98+
options.asyncComputed[key] = {
99+
get: method,
100+
...computedOptions,
101+
} as IAsyncComputedProperty<T>;
102+
delete options.methods![key];
103+
});
104+
}
92105
93106
interface IColors {
94107
hex: string;

src/main.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import isWebglEnabled from 'detector-webgl';
22
import Vue from 'vue';
33
import * as VueGL from 'vue-gl';
4-
// @ts-ignore
5-
// tslint:disable-next-line
64
import App from './App.vue';
75
import displayWebGLErrorMessage from './webglError';
86

yarn.lock

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7697,10 +7697,9 @@ [email protected]:
76977697
dependencies:
76987698
indexof "0.0.1"
76997699

7700-
vue-async-computed@^3.6.1:
7701-
version "3.6.1"
7702-
resolved "https://registry.yarnpkg.com/vue-async-computed/-/vue-async-computed-3.6.1.tgz#6b790e2125347c678d1b82b10a5b03b41d7b86d0"
7703-
integrity sha512-8FFDTqfdvKrzK5Fr7nNHZgP6sQ2hTUELTrLn25i8VW/g06MztD+FOe1gs0RYVpRkPlcrykf2hbJxNYra1c4OGg==
7700+
"vue-async-computed@https://github.com/saraedum/vue-async-computed.git#5debb7dcd81f52183be55e05b866fc43278a990":
7701+
version "3.5.0"
7702+
resolved "https://github.com/saraedum/vue-async-computed.git#5debb7dcd81f52183be55e05b866fc43278a9905"
77047703

77057704
vue-class-component@^7.0.1:
77067705
version "7.0.2"

0 commit comments

Comments
 (0)