vuejs / vue-async-data Goto Github PK
View Code? Open in Web Editor NEWAsync data loading plugin
License: MIT License
Async data loading plugin
License: MIT License
For some reason I'm having to checkout master in npm to get this to work with vue 1.x
Currently attempting to use vue-async-data
and the wait-for
directive but it does not hide elements that are inside of a vue-router
route component.
<!-- app.html -->
<body>
<router-view></router-view>
<script src="app.js" />
</body>
<!-- component.html -->
<div wait-for="async-data">
This is a child element, should this be visible?
</div>
<div v-if="!$loadingAsyncData">
This is hidden correctly.
</div>
// app.js - snippet
// component and router
var component = Vue.extend({
template: require("component.html!text"),
asyncData: function(resolve, reject) {
setTimeout(function() {
resolve();
}, 2000);
}
});
router.map({
"/": { component: component }
});
router.start(app, "body");
Edit: after reviewing the code, is it intended for the wait-for
directive to only be used inside of a component tag? In that case, it would be impossible to use it in the context of vue-router
, as vue-router
is responsible for explicitly adding route components to the DOM.
Would be awesome if this could 'refresh' one way binds when async data is received
Something like <span> Edit {{* person.name }} </span>
asyncData: function () {
var self = this
return PeopleRedux
.single(self.$route.params.personId)
.then(function (person) {
return {
person: person
}
});
},
Hello,
Is it possible to add the compatibility of this module for Vue 2.x ?
Hello @yyx990803. I think will be better if this plugin will have a support for RxJS
Hi,
looking at this example for data fetching with vue-router v2+ I understand that the async data
option has been removed and a pattern for async data very similar to this project is in use.
I'm refactoring a vue 1.x project with migration to v2 in mind, so I was wondering if my assumption is true and whether it'd be an option to adapt this plugin to work with 2.x
If so I'd might also be able to take care of the task and make a PR
Maybe loading data asynchronously is more a common case. I think Vue's core should implement this function, instead of making a plugin.
e.g. We can pass data
a function which returns a Promise.
Because of install
method is not called in mixin (called only in use
for plugins)
But according to docs
// use globally
// you can also just use `VueAsyncData.mixin` where needed
Vue.use(VueAsyncData)
it can be assigned separately to components via mixins: [VueAsyncData.mixin],
Please can this package be added to bower. The other official plugins have been added, so it would make sense if this was added as well.
Thanks.
In vue 1.0.21 there is still mechanism, that throws "[vue-async-data] not installed!" warning
while using vue-async-data as mixin.
<script>
import VueAsyncData from 'vue-async-data';
export default {
mixins: [
VueAsyncData.mixin,
],
...
asyncData(resolve, reject) {
CustomDataService.getItems().then(...
but it works properly!
When I try to broadcast event from asyncData I receive no event to child component.
// Parent with async data plugin
asyncData: function () {
var self = this;
return this.$http.get('foo.json')
.then(function (response) {
self.$broadcast('dataRetrieved', response.data);
self.data = response.data;
})
}
But when I was using broadcast without asyncData I get events to child component
// Parent without plugin
methods: {
getData: function () {
this.$http.get('foo.json').success(function (data) {
this.$broadcast('dataRetrieved', data);
this.data = data;
}).error(function (err) {
console.log(err);
});
},
}
Here is my child component, listening for events.
// Child
events: {
dataRetrieved: function (data) {
// Here should I get data, but this event is not fired.
this.data = data;
}
}
Uncaught TypeError: this._defineMeta is not a function
It looks like because of deprecation of this._defineMeta
in favor of _.defineReactive
but I could not find where defineReactive
is exposed to use it in mixin
Hi,
Do you have plan to make this vue-async-data work with vuejs2.0?
Thanks~!
hi, recently we want to add your lib on https://cdnjs.com, we use npm auto-update or git auto-update(depending on git tags) to add every released version, so could you please consider adding tags for every released version?
thank you very much!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.