callback

Have Bokeh Callback update a list instead of a ColumnDataSource?

二次信任 提交于 2020-01-01 14:53:11
问题 My question has to do with modifying this example from the Bokeh Gallery. I have a matrix m or raw data, in which every row corresponds to a pair of x,y coordinates in a transformed space (see #MockData part of code). The x,y coordinates are plotted on the left plot. I am trying to change the example so that, when I select some points in the left figure, the right figure will display line plots of the corresponding rows. I've narrowed the problem down to the point, where the right figure will

Simulate function pointer

旧城冷巷雨未停 提交于 2020-01-01 14:39:12
问题 The following class contains a method that should calculate the integral using the callback technique. package integrals; import java.lang.*; public class Integrals { public static double f1(double x) { return x*5+Math.sin(x); } public static double f2(double x) { return Math.pow(x*f1(-x),x); } public static double TrapezoidalIntegration(double a,double b,int n,double (*f)(double)) { double rValue=0; double dx; dx=(b-a)/n; for(double i=f(a);i<f(b);i+=dx) rValue+=((f(i)+f(i+dx))*dx)/2.0;

ES6 Promise patterns for exotic control flows

久未见 提交于 2020-01-01 12:10:05
问题 ES6 Promises are great. So far it’s been pretty easy to adjust my thinking from the callback idiom. I’ve found it naturally encourages more modular code, and of course error handling is much clearer. But a few times I’ve encountered flow situations that don’t seem(?) like they can be readily translated from nodebacks to promises (and perhaps that’s just that, but maybe I’m just blind to the answers). Since promises are agnostic about the next operation (or if there even is one), it seems

ES6 Promise patterns for exotic control flows

风流意气都作罢 提交于 2020-01-01 12:09:39
问题 ES6 Promises are great. So far it’s been pretty easy to adjust my thinking from the callback idiom. I’ve found it naturally encourages more modular code, and of course error handling is much clearer. But a few times I’ve encountered flow situations that don’t seem(?) like they can be readily translated from nodebacks to promises (and perhaps that’s just that, but maybe I’m just blind to the answers). Since promises are agnostic about the next operation (or if there even is one), it seems

WCF callback with multiple clients

这一生的挚爱 提交于 2020-01-01 12:08:34
问题 Can I have two different clients listening to the same WCF callback and have them both receive the same data without having to do the processing twice? 回答1: Not really - at least not directly. What you're describing sounds a lot like the publish/subscribe pattern. A WCF service basically services one client and one client only, at any given time. There are ways to do this in WCF 3.5 and better ones in WCF 4.0 - with or without Windows Azure's .NET Services. There are also other tools and

WCF callback with multiple clients

妖精的绣舞 提交于 2020-01-01 12:08:07
问题 Can I have two different clients listening to the same WCF callback and have them both receive the same data without having to do the processing twice? 回答1: Not really - at least not directly. What you're describing sounds a lot like the publish/subscribe pattern. A WCF service basically services one client and one client only, at any given time. There are ways to do this in WCF 3.5 and better ones in WCF 4.0 - with or without Windows Azure's .NET Services. There are also other tools and

Which is a better way of writing callbacks?

≯℡__Kan透↙ 提交于 2020-01-01 09:36:07
问题 Just by seeing what I've wrote now, I can see that one is much smaller, so in terms of code golf Option 2 is the better bet, but as far as which is cleaner, I prefer Option 1 . I would really love the community's input on this. Option 1 something_async({ success: function(data) { console.log(data); }, error: function(error) { console.log(error); } }); Option 2 something_async(function(error,data){ if(error){ console.log(error); }else{ console.log(data); } }); 回答1: Many people will find option

QtWebEngine - synchronously execute JavaScript to read function result

扶醉桌前 提交于 2020-01-01 08:38:13
问题 I have the following method in one of my C++ classes (using QtWebEngine): QString get() { QString result; view->page()->runJavaScript("test();", [this](const QVariant &v) { result = v.toString(); }); return result; } It is to execute test() JS function and return the result of this invocation. Unfortunately, the callback is asynchronous and the program crashes. How can I make it work? 回答1: The callback is asynchronous because the JavaScript execution occurs not only in another thread but in

Array_filter in the context of an object, with private callback

对着背影说爱祢 提交于 2020-01-01 07:43:26
问题 I want to filter an array, using the array_filter function. It hints at using call_user_func under water, but does not mention anything about how to use within the context of a class/object. Some pseudocode to explain my goal: class RelatedSearchBlock { //... private function get_filtered_docs() { return array_filter($this->get_docs(), 'filter_item'); } private filter_item() { return ($doc->somevalue == 123) } } Would I need to change 'filter_item' into array($this, 'filter_item') ? Is what I

Array_filter in the context of an object, with private callback

元气小坏坏 提交于 2020-01-01 07:42:05
问题 I want to filter an array, using the array_filter function. It hints at using call_user_func under water, but does not mention anything about how to use within the context of a class/object. Some pseudocode to explain my goal: class RelatedSearchBlock { //... private function get_filtered_docs() { return array_filter($this->get_docs(), 'filter_item'); } private filter_item() { return ($doc->somevalue == 123) } } Would I need to change 'filter_item' into array($this, 'filter_item') ? Is what I