Angular router's viewContentLoading issue did not work - angular-ui-router

I have created a set of views by using ui-router.Then I write a run() function to listen a route issue like this:
$rootScope.$on('$viewContentLoading',function(evt,config){
console.log("one is loading!");
})
So I say I want to create a movement or some kind of animate during the view content is loading,but the code above just consoled nothing.
Then I try another state called $viewContentLoaded and do the same thing,and it worked,it consoled something as expected.
But why would these two issues behave differently?

Are you positive you're setting up listeners on the correct scopes? $viewContentLoading is broadcast on $rootScope while $viewContentLoaded is emitted from the local $scope.
This StackOverflow question may help shed some light on why the 2 act different and may help you figure out what's wrong:
$rootScope.$broadcast vs. $scope.$emit
Maybe you can also add a Plunkr showing the issue? I am unable to replicate this issue.

Related

Race condition with Capybara value set

I have faced an issue while using .set(#{value}) to fill the text field in registering form, e.g: the phone number i wanna put in is 506307 then it ended up with 063075.
The work-around i have been made is executing Javascript block like
execute_script("document.querySelector('#{selector}').value = '#{value}'")
However, using the same scripts applying for Webmobile based on React.JS, the scripts above just send the text but didn't send the onChange event, which cause another element cannot be selected/clicked -> made the test failed.
I came up with another approach is to use the send_keys #{value} to trigger the key-pressed event that would make browser think there was a key-pressed event happen for that form, but it ended up with race-condition like set(#{value}) as i mentioned.
The another work-around is using What is the best way to trigger onchange event in react js , but i tend to use the native Capybara actions before making that tricky Javascript.
So, is there any other way to interact / fill the form field which won't cause that Race condition issue ?
Thanks everybody in advance.
Note: Any "solution" suggested that is purely the use of execute_script to run some JS is a terrible idea since it completely bypasses the concept of testing what a user can do and can basically make your test worthless.
The root cause of the issue here is the JS behavior attached to the input not being able to handle the key events fast enough. The proper fix would be to fix the JS, however if that's not possible there's a few things you can try
First you can try changing the clear method being used by set
element.set('506307', clear: :backspace)
or
element.set('506307', clear: :none)
If that doesn't change anything then try clicking on the input, followed by a short sleep before setting the content
element.click
sleep 0.25
element.set('506307')
If none of those work around the issue we need to know exactly what JS behavior you have attached to the input and/or what events that JS behavior is listening to.

How to get preferred channel layout from CoreAudio

I was wondering if anyone know how to get preferred channel layout from CoreAudio. I try to use kAudioDevicePropertyPreferredChannelLayout to get the channel label. However, it always shows kAudioChannelLabel_Unknown value. Is there something driver issue? or it's necessary to set some properties before asking kAudioDevicePropertyPreferredChannelLayout.
my code is here:
https://gist.github.com/ChunMinChang/ea74c8228745449873716e1d98ba956e/e61fedea3e08bcff64ef3db05931a1c757768d70
Answer by myself.
Instead of kAudioDevicePropertyPreferredChannelLayout, Using kAudioUnitProperty_AudioChannelLayout allow me to get the correct channel configuration.
Maybe it would be better if we use kAudioDevicePropertyPreferredChannelLayout to get the layout first. If it returns Unknown, then we use kAudioUnitProperty_AudioChannelLayout to get it.
Code: https://gist.github.com/ChunMinChang/ea74c8228745449873716e1d98ba956e/96b5d39e3fa7d5d6e160c53917b213f9af3ba2c9#file-preferredchannellayout-cpp

(Jmonkey Engine) java.lang.IllegalArgumentException: Cannot find animation named: 'Idle' How do I solve this? Thanks

I would like to have help with a error I'm are currently having for the Jmonkey Engine 3 and possibly help others if they are getting the same or similar message.
I keep getting this error, when I run/build the project
But when I put the model in the scene composer and go into AnimControl the animations when I play them work. The Code can be uploaded to an Image if requested.
PS : I cannot ask this question on the jmonkey official forms as I have forgetten my password and the rest email will not arrive in my Inbox.
Can you play the other animations (Head Turn for example)? Are you sure that you load the correct model and that you are in the correct position of the Node (the Node, where also the AnimControl is)? Otherwise it has to be a spelling error, for example ldle (with a 'l') instead of Idle (with an 'I').

Get list of currently dispatched events

I know this question may seem weird but I'd like to get a list of currently dispatched events.
The thing is that I am a lazy man and I would like to check if the 'checkout_cart_add_product_complete' has been fired without creating an observer for it.
So the idea is to get an array of all dispatched events and do an in_array on it :)
I thought that Mage::getEvents()->getAllEvents() would throw some info but it just returns an empty array.
I also digged a bit in lib/Varien/Event files and folders but didn't manage to be successful at creating an observer programmatically. Yep, I know, why being simple while one can be complicated ? :)
So this main question (getting a list of dispatched events) hides another (for the pure knowledge) wich would be "how to create an observer programmatically".
What do you think?
Thanks a lot!
Take a look at dispatchEvent and you'll see that events are only loaded from the assorted config.xml files, via SimpleXML. I cannot see any way to intercept this except to override Mage_Core_Model_App.
Of course there cannot be an event-dispatched-event, that would create an infinite loop, so there is no way to observe all events.
If you need to see events for development my advice would be to set a breakpoint in dispatchEvent with your debugger, that way you get to see not only the event names but also the objects passed as parameters too. I've tried other ways before but this was most convenient for me.
I need to do the same and I think it's possible to trick magento by the function getEventConfig in Mage_Core_Model_Config. You could force him to add automatically a default observer.

Sorting a view by dropdown

Hey, i've been looking around for a ajax dropdown sorter for my Views in Drupal.
Unfortunatly, i haven't found alot of usefull information about this subject.
Can anyone tell me if theres a solution already available or can help me started on a custom module by telling me which hooks i should use?
I had a similar issue. Unfortunately I wasn't able to sort the data from the database which is by far the best way. I was however able to take the data and sort it with PHP using a preprocessor function. Depending on the name of your view, setup a function similar to the following:
function templatename_preprocess_name_of__view(&$vars)
{
//Super sweet sorting code goes here
}
The name of your view needs to follow the name of the template file that it is driven by, if there isn't on you should create one. Make sure to change dashes to underscores in your function name. Hope this is helpful. If you find a way to do it from the DB I'm all ears because that would be super awesome.

Resources