scope

Scope of events from process.emit in Node.js

戏子无情 提交于 2019-12-11 05:12:56
问题 I have code to sent event like this: process.emit('event', event); I would like to listen to these event like this: process.on('event', function(event) { //HANDLING LOGIC }); It works fine when files are located in the same folder. When I located listener in other folder it is not fired. What can be a root cause of this and hwo can I handle it? EDIT: The actual problem was just a missing expose with a file including event handling. Shame on me. 回答1: The process is a single global instance.

JS - Accessing Function Parameters Array Outside of Scope

一个人想着一个人 提交于 2019-12-11 05:01:43
问题 BRIEF: I have frequented SO for years, but this is my first post. I've heavily searched SO for this, so I'm sorry if I overlooked it and this is a duplicate. function actionFunction(values) { this.defaultValues = { valueX : 2.5, valueY : 5.5 }; this.valuesRanges = { xRange : { min : 0, max : 10 }, yRange : { min : 5, max : 10 } }; }; Obviously I can access these within the function itself using this.defaultValues.valueX , etc. What I'd like to know is how to access these outside of the

d3 (or JavaScript): use local variable in another function

狂风中的少年 提交于 2019-12-11 04:54:59
问题 I'm stuck in d3.js. I'm drawing multiple SVG canvas with lines, where the length of the lines is determined by data. Each row of the data is mapped to its own SVG. What's not working properly is to draw a line at the end of another line. My code worked before I entered the data. But now as soon as I add a data value (e.g. d.uni), the second line is always drawn at the same position, namely at the last position determined by JS. Here is the code: var w = 300; var h = 250; var stemL = 100; var

{Binding elementName…} failing

て烟熏妆下的殇ゞ 提交于 2019-12-11 04:45:12
问题 I have created an dummy window with a checkbox a Button a Button inside a custom UserControl Both Buttons start out Blue, and when the checkbox is checked, they should both turn orange. However, the one inside the user control seems to be ignoring the checkbox. Why is it failing, and how can I get around this? The UserControl I want to insert: <UserControl x:Class="UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006

React - Arrow functions and this and scope

别等时光非礼了梦想. 提交于 2019-12-11 04:27:15
问题 I have the following code. let myapp = this; myref.on('value', function (snapshot) { myapp.updateUsers(); }); I am trying to get rid of the code which fixes the scope issue. Can I convert this to an ES6 arrow function? Alternatively is there a way to access the react root app? class App extends Component {} 回答1: When you are inside a class and using an arrow function then this will get its reference binding to the instance via the lexical scope, instead of dynamic binding like you get with

PHP Class Database Connection Scope Issue

痴心易碎 提交于 2019-12-11 04:22:48
问题 For a new project that I'm doing in PHP I've created an SQLMethods class to connect to the database and perform queries. Tonight was the first night that I actually got to test it (I wrote it a week or so ago and forgot about it) and an unexpected error occured: When it was calling my ExecuteQuery() function, it wouldn't use the database I selected in the constructor. The constructor: public function SQLMethods() { $SQLConnection = mysql_connect($SQLDBAddress, $SQLUserName, $SQLPassword); if

How to store data is session scope in Spring

天大地大妈咪最大 提交于 2019-12-11 04:09:18
问题 I have created two object in session scope like this @SessionAttributes({"userObj","simpleValue"}) in my controller. I am adding a user object and String at these variables in my controller like this: modelAndView.addObject("userObj", user); modelAndView.addObject("simpleValue", "Hello World"); User class is a simple class with 2 properties id & name . Lets say I created this in a controller called Controller1 which shows Page1 . I can see the data of my session variables in page1 . Now I

“this” keyword inside closure

做~自己de王妃 提交于 2019-12-11 04:04:14
问题 I've seen a bunch of examples but can't seem to get some sample code to work. Take the following code: var test = (function(){ var t = "test"; return { alertT: function(){ alert(t); } } }()); and I have a function on window.load like: test.alertT(); That all works fine. However, when I try to explicitly set the context of t inside the alert() in alertT , I just get undefined. I've tried: var that = this; alert(that.t); //undefined I've tried: return { that: this, alertT: function(){ alert

Spring session scoped objects in @Scheduled

删除回忆录丶 提交于 2019-12-11 03:54:25
问题 In spring, I have a lot of code that uses session beans defined like this: @Scope(value="session", proxyMode=ScopedProxyMode.TARGET_CLASS) In my webapplication all is fine, since a session scope is available. In my JUnit tests, all is also fine since i'm using a WebContextTestExecutionListener (link) that registers a thread scope for the session scope But when a method with @Scheduled is called, I get an exception since there is no session scope. Now my question is: How can I register a

More About PHP OOP - Classes within Classes

江枫思渺然 提交于 2019-12-11 03:50:46
问题 I have been told that a class cannot be defined within a class in PHP. However, in my own example this seems to work which has me confused: class_test.php: require('class_1.php'); new class_1 //Need $missing_variable here. class_1.php class class_1{ public function function_1(){ function callback_function(){ echo "A Callback"; $missing_variable = "Where Did I Go?"; } require('class_2.php'); new class_2('callback_function'); } public function __construct(){ $this->function_1(); } } class_2.php