NativeScript-Vue - Navigation from outside component - nativescript-vue

My application is receiving push notifications, when a push notification arrives, I would like to navigate to a specific component of the application.
The problem is that the callback in which I'm handling the push notification is not a vue component and so I can't
call this.$navigate.
So I tryed to inject directly Vue:
import Vue from 'nativescript-vue'
and then:
Vue.$navigateTo(Instrument);
But nothing happens. (The method is correctly called).
I have no other idea to addressing this problem. Any hint?

I should have used:
Vue.navigateTo(..) or Vue.prototype.$navigateTo(..)

Related

How to dispatch an action to the redux-devtools store for importing a state from a component?

I'm currently trying to implement a panel integrated in my angular application which will allow me to import whatever json state file exported from redux-devtools using the same import feature as redux-devtools.
My application is properly integrated with #ngrx/store-devtools.
I can't figure out how to retrieve the devtools store from my component to then dispatch the action IMPORT_STATE as i saw on redux-devtools code:
store.liftedStore.dispatch({type: 'IMPORT_STATE', ...nextLiftedState});
The goal is to manually trigger the import state feature from redux-devtools but within a component of my application directly.
Is it possible to do that? And how to inject this store in my component to then use it?
Thanks in advance,
EDIT:
Actually, what i am trying to achieve is to have a component in my application which allows me to import different state (as json file) that i would have previously recorded from the redux-devtools extension to reach any pages of my application. Thus, this component needs to access to the redux-devtools store and dispatch the action IMPORT_STATE. What i did for the moment seems to not trigger the reducer for IMPORT_STATE action of the redux-devtools store. I think i'm missing something to include the redux-devtools store from the angular application.
Do you have any idea of how to achieve that?
Thanks in advance,
To dispatch into the store from the dispatcher in the redux devtools you just enter in the action definition as json and then click dispatch.
for example:
{
type: 'IMPORT_STATE',
... whatever payload contents you need here ...
}
To open the dispatcher, click the little keyboard button in the middle at the bottom of the devtools.

How to Disable `back` and `forward` button of the browser window

In my applicaiton, I requried couple of things to be added.
No forward/Back Browser button should work for reach a hash.
Instead of brower back forward, there should be a back and forward button has to added in the applicaiton itself.
how to achive this both?
I am looking for a component to use globally for both 2 requriements.
Thanks in advance.
Disabling the native back/forward buttons of the browser in Ember.js is quite unusual but could possibly be achieved by using the NoneLocation class. To enable that open the config/environment.js file of your app and change the locationType property to none.
If you want to display back/forward buttons in your app you can use the History API and specifically window.history.back() and window.history.forward()

Ember observer when session is active on page load

I am writing a EmberJS web application. I have a piece of code which should run only when the page has completed loaded and the session authentication is complete.
I tried setting an observer on session.isAuthenticated but it does not seem to be working.
Any thoughts?
Thanks
You can use didTransition hook of the particular route. You need to define it in actions hash, and dont forget to return true for bubbling to the parent route.
Inside didTransition hook, if you want to run some thing after the page has been rendered, then you can try,
Ember.run.schedule("afterRender",() => {
//you code
});

Ember ApplicationRoute with other Routes

I have a basic ember question here. I'm looking to set up an ember ApplicationRoute that gets loaded immediately, and have all other routes extend from this application route. I would like the data that the ApplicationRoute loads to be loaded on every page transition. Is this possible? FYI I'm also using ember-data and rails as an API.
Thanks!
If you want a real time data pushed from a server you should try extending your ApplicationAdapter to handle data from websocket connection and push in to the store object. A nice example of parsing model data from websocket connection may be found in API docs http://emberjs.com/api/data/classes/DS.RESTSerializer.html#method_extract

Where/how to create a background function/thread in Ember.js?

I would like to run a function in the background of an Ember App. I am also using Ember Data. Does Ember.js have a particular way to create a background function/thread?
Say I have a function with a while(true) that runs forever doing the things I would like it to do. Where should I put that function in an Ember App?
Update: Here are some ways (if clickable, you can to see an example in jsbin):
Use Ember.run.schedule on Ember.run.later. See this post and the api.
Using a simple setInterval() in ApplicationRoute. The UI seems to be running smoothly.
Use setInterval() inside a Web Worker.
How is Ember.run.schedule or later better than setInterval?