Angular.js view not being updated after receiving message from broadcast
Date : March 29 2020, 07:55 AM
To fix this issue I agree that by the time the event arrives the model should have been updated. It looks like a bug in angular. Till then you can emit the event inside a $timeout if that works for you. $timeout(function() {$rootScope.$broadcast("model-update");}, 0);
|
Node.js view not receiving updated data unless route is re-saved
Date : March 29 2020, 07:55 AM
hope this fix your issue I tried searching for this answer but couldn't find anything. , You need to put the request into the route: var express = require('express');
var router = express.Router();
var request = require('request');
var url_fx = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20(%22EURUSD%2CUSDJPY%2CUSDCAD%2CUSDCHF%2CGBPUSD%2CAUDUSD%2CNZDUSD%2CUSDMXN%2CEURGBP%2C%20EURJPY%22)&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
var fx_feed;
/* GET home page. */
router.get('/', function (req, res, next) {
request(url_fx, function (err, resp, body) {
body = JSON.parse(body);
fx_feed = "";
if (!body.query.results) {
fx_feed = "No results found. Try again.";
} else {
fx_feed = body.query.results.rate;
console.log(fx_feed)
console.log("updated")
}
res.render('index', {
title: 'Title',
fx: fx_feed
});
})
});
module.exports = router;
|
View class is not receiving updated Model class data
Date : March 29 2020, 07:55 AM
Does that help In the code snippet above, shipModel object from main() and shipView.model are two distinct objects. You can either let your shipView be aware of the model using a setter in spaceshipView, or call shipView.model's methods directly.
|
How to reload data from backend without refreshing the window?
Date : March 29 2020, 07:55 AM
this one helps. What I did was navigating to the same URL I'm on: this.router.navigate([this.router.url]); @NgModule({
imports: [
RouterModule.forRoot(
[
{ useHash: true, enableTracing: DEBUG_INFO_ENABLED, onSameUrlNavigation: 'reload', scrollPositionRestoration: 'disabled' }
)
],
|
Refreshing data showing on the screen from backend in my case
Date : September 21 2020, 11:00 AM
Any of those help Hi user842225, This will an interesting discussion/opinion rather than a QA. object JavaApplication2 {
private var beepHandler: ScheduledFuture<*>? = null
private var scheduler: ScheduledThreadPoolExecutor? = null
private var interval: Long = 0
@JvmStatic
fun main(arguments: Array<String>) {
val scan = Scanner(System.`in`)
println("How often so you want me to do refresh this request? e.g 10 or 5")
interval = scan.nextLong()
startExecutor(interval)
}
/*One of the most important method in our program, this helps start fresh Executor and
timed it according to what we want*/
private fun startExecutor(interval: Long) {
scheduler = Executors.newScheduledThreadPool(1) as ScheduledThreadPoolExecutor
/*Below method just in case you wanna be more bad-ass, you can simply use this same scheduler to
run the new task which is of a different time interval, this I can't really explain now
but you can look at how be to make use of this to save recreating of Executor all the time
you need to change the operation. Well, not really compulsory, so I will comment it out*/
// scheduler.setRemoveOnCancelPolicy(true);
//Now we instantiate and schedule
beepHandler = scheduler!!.scheduleAtFixedRate(MarketClass(), 1, interval, TimeUnit.SECONDS)
/* Now, below is the trick, we simply set the repetition operation to one day!
basically no one stays on a particular screen of an app for 24hrs (Weird if anyone does!).
Good thing here is that using ScheduledThreadPoolExecutor promise us that our*/scheduler!!.schedule({
beepHandler!!.cancel(true)
scheduler!!.shutdown()
}, 1, TimeUnit.DAYS)
}
fun endExecutor() {
beepHandler!!.cancel(true)
scheduler!!.shutdownNow()
}
/* Here should be our network request subclass that simply implements Runnable because that's what @ScheduledThreadPoolExecutor needs
I really wish I can explain this @ScheduledThreadPoolExecutor further!*/
internal class MarketClass : Runnable {
private var x = 0 //I'm using this just show that we can cancel the operation half way or anytime we like.
override fun run() {
getMarket() //Here is the calling of the method that does get markets by name ....
//========TESTING SOMETHING======
println("Even if the world is > 2020: I won't let go of Science!!! ")
/* here when we get to 10 we want to cancel the operation, this is imagine
to be a user switching to another screen where same operation will be done
but with different time interval, so let say onclick we just do the cancel
and shutdown the scheduler, note: not necessarily done here! can be done anywhere
since our (beepHandler) and (scheduler) are reachable.*/
x++
if (x == 10) {
println("Wanna visit another market ???\nMaybe the Jedi markets ??? ")
endExecutor()
}
//=======END TESTING SOMETHING=====
}
}
private fun getMarket(){
println("Bing! Bing!! Bing!!! Welcome to Illuminations Market... <- (0) . (0) -> we have souls to sell")
//ApiCall().getMarketByName(param, object: Interface{
// bla bla bla ...
// })
}
}
1. startExecutor(interval: Long)
2. endExecutor()
3. MarketClass : Runnable{}
4. getMarket()
|