I want to attach YUI modules synchronously.
Given the YUI modules are already on the page
When I run: console.log YUI().use('base').Base
Then I get `undefined`
However,
When I run: YUI().use('base', (Y) -> console.log Y.Base)
Then I eventually get the Y.Base ctor function
It looks like loader is attaching async as it works fine using the callback method. IIRC the first method is supposed to work too though. What am I missing?
If you're using YUI in a controlled environment like Node.js, then you should be able to use useSync configuration:
YUI({ useSync: true }).use('base').Base
But in a browser, or any other client runtime you should stick to the asynchronous nature of Y.use so loader can do its job of computing the proper list of modules to be attached based on the feature detections etc. Having the modules included manually in the pase is just not enough. Imagine the scrollview-base in IE, which requires an special module called scrollview-base-ie, unless you do detection when building the initial markup that includes that module only when running in IE, you will have a missing module. Again, stick to the asynchronous pattern when loading stuff.
YUI modules really want to be called through a Y object in a callback. If you know for sure that all the code you need is loaded on the page, you can attach them all synchronously with a use *. See https://github.com/evangoer/yui3-cookbook/blob/master/examples/loading/use_synchronous.html for an example.
Related
As I am using next-i18next, I figured that I am calling language API (json format) when I build the next.js project by using i18next-http-backend in next-i18next.config.js
Downside of it, is that I need to REBUILD the project when language data is changed ...
So, I found this function called i18n.reloadResources() which works perfectly inside getServerSideProps(). (The reason why I want to avoid server-side rendering is that the language data is way too big. more than 800kb, for one language and I have 15 language translations. Every pages with 800kb API call is miserable ... I think)
However, I do not want to call API every time I re-render the page, and I found out about Incremental Static Regeneration (ISR, on-demand), but seems like it does not work the same way. In other words, it is not working.
Any suggestions for this type of situation?
I am developing a simple farming game backend using meteor.
So Server needs to check all players farm data and based on that for example increment
production:0
field each second if player has a farm.
What is the best way to do that ?
Should i use Meteor.setTimeout()
You should use Meteor.setTimeout if you don't manually want to bind fibers to the callback function.
Related issues:
What's going on with Meteor and Fibers/bindEnvironment()?
Meteor wrapAsync or bindEnvironment without standard callback signature
However, you can also use the native JS setTimeout but you will have to manually bind a fiber to the callback (if you aim to use for example Mongo) using Meteor.bindEnvironment or Meteor.wrapAsync.
Another interesting tool is Meteor.defer which is similar to Meteor.setTimeout(func, 0) and allows to execute code in the background. Beware of several layers of callbacks when mixing with Meteor.setTimeout.
Ans yet another tool when executing complex services in a method is this.unblock.
Applying these tools in an appropriate way will make your timer based update possible.
I am using wxWidgets to download the contents of a website into a wxHtmlWindow control. This works flawlessly, except for one thing. The entire gui seems to freeze while the data is being downloaded, which is highly problematic for my application. In most other wxWidgets class methods, events continue to be processed automagicly for you even if the call in question is said to be blocking. This does not appear to be the case here, and I am wondering how I might tell wxWidgets to download the page in the background? I am currently using the LoadPage method.
I guess I could use a second thread, but with the restrictions that wxWidgets imposes on changing the state of any window through any thread other than the main one makes me hesitate to dive into this. Is there a better way? The raw http class, for instance, does not block the window while it's downloading so I don't understand why wxHtmlWindow, which surely must be using the raw http class internally, does not have the same behavior.
Unfortunately wxHtmlWindow uses synchronous sockets to fetch contents of a URL. Call hiearchy goes like this: wxHtmlWindow -> wxHtmlParser -> wxFileSystem -> wxURI -> wxHTTP -> wxHTTP::GetInputStream . The GetInputStream method will use the open a socket in blocking mode.
You will need to use a separate thread to fetch the contents of a website.
I am currently trying to use the "Invocation tags" of Mate to call my web services and delegate the WS-responses to my fault/result handlers.
I want to use the generated proxies, provided by the Flex Builder, and not the plain <WebService> or <WebServiceInvoker> tags.
I actually failed using several techniques:
<WebServiceInvoker> does not work with the generated proxies.
<AsyncMethodInvoker> needs some complicated successType that I could not get to work with the WS-calls. And defining the events seems redundant to me. I want it simple and easy to read, the code will be touched by other people than me!
<MethodInvoker> can't use instances, and it also can't handle the proxies' AsyncToken
<DelegateInvoker> Looked fine at first. It calls the service but doesn't fire valid result events (infinite busy cursor). Even though i can successfully bind to the XYZ_lastResult of the WS-proxies, and a WS-call results in getting valid data from the WS-backend, the <faultHandlers> and <resulthandlers> are not executed. There is some solution for the DelegateInvoker that changes code in the generated proxies, which i definately do not want to do!
So here is my question: Is there a simple(!) way of using default Flexbuilder generated proxies with the Mate Invocation tags?
It appears that your request is not that uncommon to Mate. Check out this couple of threads in their forum:
http://mate.asfusion.com/forums/topic.php?id=424
http://mate.asfusion.com/forums/topic.php?id=421
The solution is to modify some bits of the auto-generated code... which in a way ruins the whole point of using code generation.
An existing (though incomplete) FLEX3 project was given to us to finish (always a nightmare).
It is quite small but highly abstracted (contains well over 150 files to support only about 10 page views). I'm attempting to trace a single mouseclick event through this maze.
Is there a way to print out an actionscript trace and/or component flow using the debugger (or any other tool that anyone knows of)?
The flash.txt file appears worthless since it doesn't contain ActionScript calls and/or component flows.
Thanks
This will print your execution graph:
Trace.setLevel(Trace.METHODS, Trace.LISTENER);
Trace.setListener(handleMethods);
function handleMethods(fqcn:String, lineNumber:uint, methodName:String, methodArguments:String):void
{
trace(methodName);
}
Oof. Yeah, always.
The Profiler might give you useful information, but you need to pay for FlexBuilder Pro to get it, if you don't already have it. I'm not real handy with the Profiler, so I may be off base with that advice. It would be worth checking into, though, if you are already familiar with other profiling tools.
I would probably just start looking at every point that .addEventListener(MouseEvent.CLICK occurs in the code - and .addEventListener("click", just in case the previous developer chose not to use the constant, for some reason.
Obviously, that could show up a lot in 150 files, but that's how I would go about it.
I would also look at any custom events that could get into the mix. Because maybe the CLICK event is handled at some point and the handler dispatches a custom event. And maybe the handler for that custom event dispatches another custom event. Or dispatches a MouseEvent.CLICK event, etc.
Hope that helps. Good luck...
Check out
http://jpauclair.net/2010/02/10/mmcfg-treasure/
esp.
AS3Trace = 1|0
This one is also very useful for
debugging It trace every single call
to any function that is being called
in the SWF at runtime! It’s like
expending the StackTrace to the full
software run time.
And many more.