Comments (3)
Hi, what do you mean when you say "to query a data set for changes before reloading"?
from laravel-widgets.
Cheers for getting back to me, I've amended the question a little bit as I wrote it in a rush. I thought of two use cases that I'm trying to achieve that aren't immediately obvious ( or they are, but it seem I'm going about it wrong).
For example: I have a reloading widget that is reading values from a data set. At present, after the timeout the widget will refresh. However what I'd like is to query the table for changes and only call the run function if there has been a change since the last reload. My work around off the top of my head is:
protected $timeLastModified;
public function pollData()
{
// Check last modified of some data source, update $timeLastModified if applicable and return a bool
}
public function run()
{
if (pollData()) {
return view("widgets.recent_news", [
'config' => $this->config,
]);
}
}
Is there are way of hooking up run function of a widget to Events in Laravel, so that the need for the above is not needed. This may remove the need to put this type of functionality within a reloading widget.
from laravel-widgets.
public function run()
{
if ($this->pollData()) {
return view("widgets.recent_news", [
'config' => $this->config,
]);
}
}
The problem is that it doesn't stop the widget from being reloaded. It's gonna be replaced with the blank content in this case. The widget MUST be reloaded each time to attach another setTimeout()
handler for the next iteration.
So, there is nothing I can do for you here I'm afraid.
If you really need to do an extra check before reload just do it manually.
- Make widgget not reloadable
- Write your own javascript reloader using
setInterval()
. Make an ajax call to check state and reload widget manually by another ajax if it's needed.
Not a big deal.
from laravel-widgets.
Related Issues (20)
- Passing variables to widget HOT 8
- reloadtimeout not working HOT 2
- Can i use laravel-widgets in jquery drag and drop HOT 1
- JavaScript callback on async widget HOT 4
- Accessing config array of widget externally HOT 1
- Cache forever HOT 3
- Compatible for laravel 8 HOT 1
- laravel widget async error HOT 3
- Composer killed on composer require arrilot-widgets HOT 1
- Unable to access Auth::id() in asyncWidget HOT 3
- Can not pass variable to Widget (via Config Array) HOT 5
- How do using ajax for pagination HOT 1
- Pricing of spaces HOT 1
- asyncWidget with chart data not showing anything HOT 3
- parseFullWidgetNameFromString breaks namespace with caps and lower case characters HOT 1
- Issue Wrap same group with a class (PS: not each) HOT 1
- PHP 8.2 deprecation error HOT 1
- Delay loading of asyncWidget? HOT 1
- Can we rearrange folder and file structure HOT 1
- jQuery is undefined
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-widgets.