NgRx How to launch a feature module from another module - ngrx

I have three modules: AppModule, ModuleX, ModuleY.
In ModuleX I get and store data with NgRx but it only does so If I route to one of the components of ModuleX's and trigger OnInit lifecycle hook. I need to access that data in ModuleY.
Is there any way to do that,can I globally access to data that stored in the state from anywhere?

Related

Setting up default preloaded data in tests inside in RTK query

I am migrating certain reducers written with the duck pattern to RTK and RTK Query.
As part of that i am moving data out of the reducer and into a common createApi call in a file.
There are some tests written (for the older redux code) - where instead of calling an api endpoint - the data is directly set in redux store - passed as initialData.
import store from 'singleton-store'
function renderApp(children, initialData){
return <Provider store={store}>{children}</Provider>
}
//write a test using renderApp to test a redux connected component
But now since I am using RTK - query - I cannot set this data in older redux store.
It can only be set once the api is called and data is set via the createApi call.
How can I prefill api data in the store instead of calling an api - as part of running my test suite in React testing library.
I saw this issue and what I want to do is exactly this:

Get same object from service into several component in Vue.js

Here is the context :
on a Vue project I have a service workspaces.js that return the current Workspace for my user
I have to use this workspace from several components (header, main content, menu, etc.)
This object is binded with firestore with onSnapshot API
This object is reactive too with reactive API from Vue
On vuex I use package vuex-persist to have persistance on reload
I tried to save the current workspace in the state of vuex store, but with the different tools used (onbinding, persist, reactive) this don't work properly and data binding is not always working.
Now I want to just save the id of the workspace in vuex and get current Workspace from my service.
However to avoid multiple requests to firestore, I want to use the same object in each components that need the workspace. I have to use a kind of Singleton.
I thought about make a variable exported from the service that store the current Workspace. I wonder if this is reliable or not, I don't know how do import work exactly. Will be the same instance of my service in each component that use it ? Is there a risk that one component get the workspace and an other one get null ?

How to capture user who triggered Airflow DAG

I've enabled RBAC as environment variable in docker-compose file.
- AIRFLOW__WEBSERVER__RBAC=True
I want to capture the user who kicked off a dag inside my dag files.
I tried using from flask_login import current_user. But, I get the value of current_user as None.
May I know how to capture user details using RBAC?
According to Airflow documentation as part of RBAC security model that is handled by Flask AppBuilder (FAB):
Airflow uses flask_login and exposes a set of hooks in the
airflow.default_login module. You can alter the content and make it
part of the PYTHONPATH and configure it as a backend in
airflow.cfg.
Flask-login module provides user management operations, thus you can fetch current user within a dedicated property flask_login.current_user, adding
some extra fields, as described in #3438 pull request:
if current_user and hasattr(current_user, 'user'):
user = current_user.user.username
elif current_user and hasattr(current_user, 'username'):
I suppose that you can use current_user.user.username to fetch a user login.

Restore the previous saved status into redux

We're using redux and immutable objects on our redux store.
The scenario is that a user might dump the current store status into database and later the user might be able to restore it.
I'm a newbie to redux.
Is there any keywords to search for this kind of techniques?
We will try to dump the status into JSON format and reload it from database.
The key word is "persistence". There's dozens of existing libraries for persisting Redux state already - you can either try using them as-is, or look at how they work and implement some of the approaches yourself.
To actually persist the state, you'd normally either do it in a store subscription callback, or in a middleware. Then, as part of your app's setup process, retrieve the persisted state (from the server or localStorage or wherever you persisted it), and pass it as the second argument to createStore(rootReducer, preloadedState).
I have used window.localStorage for this.
const MyReducer = (state,action) => {
switch(action.type){
...
case 'SAVE_STATE':
stateString = JSON.stringify(state.toJS())
window.localStorage.setItem('applicationState', stateString)
return state
}
}

Windows Workflow - Creating a reusable task list (bookmarks?)

I'm looking at migrating business processes into Windows Workflow, the client app will be ASP/MVC and the workflows are likely to be hosted via IIS.
I want to create a common 'simple task' activity which can be used across multiple workflows. Activity properties would look something like this:
Related customer
Assigned agent
Prompt ("Please review PO #12345")
Text for 'true' button ("Accept")
Text for 'false' button ("Reject")
Variable to store result in
Once the workflow hits this activity a task should be put into a db table. The web app will query the table and show the agent a list of tasks they need to complete. Once they hit accept / reject the workflow needs to resume.
It's the last bit that I'm stuck on. What do I need to store in the DB table to resume a workflow? Given that the tasks table will be used by multiple workflows how work I instantiate the workflow to resume it? I've looked at bookmarks but they assume that you know the type of workflow that you're resuming. Do I need to use reflection or is there a method in WF where I can pass a workflow id and it will instantiate it?
You can use workflow service and control its via ControlEndPoint.
For more info about controlendpoint you can refer at
http://msdn.microsoft.com/en-us/library/ee358723.aspx

Resources