Retrieving a list of actions triggered: Redux

In my Angular project, I am utilizing Redux to manage state and handle API calls. While exploring the redux devtools, I discovered a comprehensive list of executed actions. Is there a method to access a similar list of actions triggered within my angular application?

My goal is to transmit this action log to the backend for additional processing.

Are there any available solutions for achieving this functionality?

Answer №1

In the past, I have implemented a logging middleware for the store. For reference, you can check out this example: https://github.com/Webiks/angular-redux-middleware-example.

Essentially, this middleware captures all actions, allowing you to either manipulate them based on the actions or pass them onto the next function for the store to proceed.

export function loggerMiddleware(store) {
  return function (next) {
    return function (action) {
      // Displaying a message and action log
      console.log('Hello, this is your captain speaking.', action);
      // Proceed to the next action
      return next(action);
    };
  };
}

You could also rewrite it as follows to make it more concise:

export const loggerMiddleware = store => next => action {
      // Displaying a message and action log
      console.log('Hello, this is your captain speaking.', action);
      // Proceed to the next action
      return next(action);
    };
  };
}

Answer №2

Looking for a quick solution to extract them in less than 30 seconds? This method may seem a bit rough around the edges, but it could do the trick for you.

Check out this link for detailed instructions

  • Simply type __REDUX_DEVTOOLS_EXTENSION__ into the console.
  • Double-click to open the source in VM.
  • Apply pretty-printing.
  • Add a breakpoint at line :356.
  • Return to the tool and navigate to an action. This should trigger your breakpoint.
Object.keys(t.actionsById).forEach((id) =>
  console.log(t["actionsById"][id].action.type))

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How do I define the type of a class property in TypeScript?

I am currently working on my own implementation of Client-side rendering and I need to define the data structure for my route object. The format is shown below: import Post from './Post' export const route = { path: '/post', c ...

Unable to retrieve values from nested objects in component.html

Hey fellow tech enthusiasts, I'm currently dealing with a complex nested JSON object retrieved from an API. Here's a snippet of the object: profile : { title:"Mr", personalInfo:{ fullNames: "John Doe", id ...

CSS - Text and dropdown misalignment due to spacing issue

I'm looking to decrease the spacing between the text "Allow type of Compartment Option" and the dropdown box. Here is the code snippet being used: .cl-checkbox { padding-left: 20px; padding-bottom: 10px; padding-top: 20px; ...

Backdrop styling for Material-UI dialogs/modals

Is there a way to customize the semi-transparent overlay of a material-ui dialog or modal? I am currently using material-ui with React and Typescript. https://i.stack.imgur.com/ODQvN.png Instead of a dark transparent overlay, I would like it to be transp ...

Is the code executed within a specific zone, and if it is, what are the reasons and methods for

Recently, I came across the code for the angular material google map library, and most of it made sense to me. However, there is one section in particular that still puzzles me (found in map-event-manager.ts). /** This method returns an observable that ad ...

What is the method for retrieving service values in Angular2?

I've been following the Angular2 tutorial steps at this link: https://angular.io/docs/ts/latest/tutorial/toh-pt4.html There's a particular syntax used to return service promise information back to the component, as shown here: getHeroes() { t ...

The clash of dependencies in Transloco

Currently, I am in the process of integrating the Transloco package into my Angular Ionic project that I compile using VSCode. My Angular version is 13.3.0. Upon executing the installation command: ng add @ngneat/transloco I encounter a series of terminal ...

Typescript issues arise when a library lacks any available types for download

I attempted to incorporate the react-keydown library into my project, but encountered the following error: Could not find a declaration file for module 'react-keydown'. '/home/path../node_modules/react-keydown/dist/index.js' implicitl ...

Connecting table checkboxes to buttons in Angular 4.x: A step-by-step guide

Exploring Angular 4.x for the first time and faced with a challenge. I have created an HTML table where each row contains a checkbox and buttons. My goal is to link the checkboxes with the buttons in such a way that when a checkbox is checked, the correspo ...

Exporting a constant as a default in TypeScript

We are currently developing a TypeScript library that will be published to our private NPM environment. The goal is for this library to be usable in TS, ES6, or ES5 projects. Let's call the npm package foo. The main file of the library serves as an e ...

Testing asynchronous actions in React Redux

Currently encountering an error while testing async actions. The error message reads TypeError: Cannot read poperty 'then' of undefined, pointing to the line below in my code. return store.dispatch(actions.fetchMovies()).then(() => { Below i ...

Tips for maximizing the state value when using useSelector() in React

I need help improving the way I use the useSelector function. Below is the code in question: const { addressList, deleteUserAddress, favouriteAddress, userAddressAfterUpdate, details, tokens, } = useSelector((state: RootState) ...

Exploring Realtime Database Querying with Firebase 5.0

I'm struggling to retrieve all the data from my RTD and store it in an array for iteration. The code below is returning 'undefined'. What could be the issue? export class AppComponent { cuisines$: Observable<any[]>; cuisines: any[ ...

Sending selected IDs from the JSON data

In my project, there is a JSON file named "workers" which contains information about all the workers. I have created a select component to display the names of the workers like this: https://i.sstatic.net/0Glyf.png Currently, I am selecting some workers ...

Navigating back to the login page in your Ionic V2 application can be achieved by utilizing the `this.nav

Running into an issue with navigating back to the login screen using Ionic V2. Started with the V2 tabs template but added a custom login page, setting rootPage = LoginPage; in app.components.ts. When the login promise is successful, I used this.nav.setR ...

Utilizing multiple page objects within a single method in Cypress JS

I have been grappling with the concept of utilizing multiple page objects within a single method. I haven't been able to come up with a suitable approach for implementing this logic. For instance, consider the following methods in my page object named ...

The where clause in the Typeorm query builder instance is not functioning properly after its common usage

When fetching data for my relations, I opted to use QueryBuilder. In order to validate certain get request parameters before the index, I established a common QueryBuilder instance as shown below. // Common Get Query const result = await this.reserva ...

How to prevent duplicate database entries in Angular forms?

Currently, I am working on a project using Angular and TypeScript. The goal is to retrieve a list of users from an API and allow for the addition of new users. However, I am struggling with determining how to verify if a user with a specific name already e ...

Is there a way to extract data from the Redux state in a React component?

Seeking assistance with making an API request from Redux, followed by saving the data in my React state (arrdata). Although the API call is successful, I am facing challenges updating the App.js state based on the Redux API call. Any suggestions or insig ...

What exactly does "nothing" mean in Node when using async await?

I have a method as shown below: private async sendToAll(clients) { for(const client of clients) { this.send(client, message); await true; // What should I put here to allow the rest of the application to continue executi ...