Is it possible to transfer a Vuex getter to a non-Vue.js component module while maintaining reactivity?

Consider the following scenario: I have a module where I need to perform certain tasks repeatedly, and these tasks depend on a value obtained from a getter that is not updating correctly. How can I ensure that this getter stays in sync with my Vuex state? Thank you.

Within my Vuex:

import { start, stop } from './externa-module.js

START_ACTION ({getters}) {
   start(getters.myVuexGetters);
}

Within my external-module.js

let myVuexGetter = null;

function doSomeStuffRepeatedly(){
  console.log(myVuexGetter);
}

export function start(importedGetter){
   myVuexGetter = importedGetter;
   doSomeStuffRepeatedly();
}

Answer №1

Seems like passing a single getter isn't an option, but rather a whole getters object obtained from the action. I am open to learning if anyone has a more optimal solution.

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

`Incorporating ordered indices within two ngFor loops?`

Below is a demo code where I am explaining my goal through comments: product.component.html <div *ngFor="let item of items1"> <div *ngFor="let item of items2"> <input type="text" value="{{data[getNumber()]}}"> //I aim to fe ...

Checking for the Presence of a Word in a String Using jQuery

I'm currently developing an application that allows users to click on usernames to add them to a reply list. The issue I am facing is that if a user with a similar username is already added, the system mistakenly identifies the new username as already ...

Contrasting {} and {} as any in TypeScript

Seeking clarity on TypeScript, what sets apart (foo and foo2) from (foo3 and foo4)? (foo and foo2) as well as (foo3 and foo4) produce identical results, yet during compilation, a red underline appears under foo2 and foo3. https://i.stack.imgur.com/lWaHc. ...

AngularJS service does not halt for the success function to complete

I am facing an issue with my service where the success function in the controller is not being executed immediately. The compiler is parsing the lines after the service call, which is not the desired behavior. In debug mode, I noticed that there is a del ...

Discover the sleek and sophisticated method of shifting a div on scroll with Bootstrap

Is there a more elegant way to position the div in such a way that it stays on the top right while scrolling down on all screens, without causing the layout to be messy on tablets and other devices? I am currently using Bootstrap. You can see a DEMO here ...

Confused within the realm of javascript's scope

Hello, I'm looking for some assistance with the code snippet provided below. My goal is to call the function doTheSlide() from within the slide event function in JavaScript. However, I seem to be struggling with understanding scope in JS. Could someo ...

Increase the time of a Date by 10 seconds

Is there a way to increase the time of a JavaScript date object by 10 seconds? For example: var currentTime = new Date(); var currentSeconds = currentTime.getSeconds() + 10; currentTime.setSeconds(currentTime.getSeconds() + currentSeconds); ...

Using .slice in combination with a media query allows you to specify different subsets

Is there a way in React to only slice objects when the screen width is 600px or less? Here's the code I'm currently using to determine the screen size: const [matches, setMatches] = useState( window.matchMedia("(max-width: 600px)").matches ) ...

The CSS selector is not properly adhering to the parent restriction as it attempts to find the div childCollapsible that has the attribute data-onthemovecollapsible set to true

Imagine a scenario that is much more complex, but let's try to simplify. I am attempting to choose the siblings of an element with the class 'sss' using $('.sss').parent().parent().find(">div.childCollapsible>div[data-onthem ...

The functionality of the webservice is not functioning properly

I'm currently working with Express and NodeJS to create a simple hello world webservice. I am attempting to call this webservice in ReactJS using Axios, but I am encountering issues with the response from the webservice. Below is my code for the webse ...

Issues with implementing KendoUI's datepicker in conjunction with Angular

My index.html file contains the following imports: <script src="content/js/angular.js"></script> <link href="content/js/kendo.common-material.min.css" rel="stylesheet" /> <link href="content/js/kendo.material.min.css" rel="styleshe ...

Access the socket.io administrator portal

Every time I attempt to connect to Socket.IO Admin UI, this is what unfolds: (https://i.sstatic.net/JYqqf.png) the server code : const io = require('socket.io')(3001,{cors: {origin:["https://admin.socket.io","http://localhost:8 ...

Variables from a node.js module

I am having trouble extracting a variable from a node.js module. My goal is to create a module that interacts with an authentication system, and it currently only returns a token. I require this token in the main.js file so that I can call other modules an ...

The dynamic value feature in Material UI React's MenuItem is currently experiencing functionality issues

Whenever I use Select in Material UI for React, I encounter an issue where I always receive undefined when selecting from the drop-down menu. This problem seems to occur specifically when utilizing dynamic values with the MenuItem component. If I switch to ...

What could be causing the issue with this jQuery selector for the parent form element?

I created a form that connects a button with an attribute, but it's not hiding the parent("form"). However, when I try this, it works. $($("[editFormContent]").attr("editFormContent")).click(function(e) { e.preventDe ...

Retrieve information on input type hidden using Vue.js

Every time I attempt to retrieve the data "Id" from my list, the script returns the wrong Id. I specifically need the Id from that field, but the value returned is incorrect. <input type="hidden" name="Id" id="Id" v-mode="todo.Id"> I have resorte ...

Navigating the realm of POST requests in Node.js: A comprehensive guide

Attempting a POST-request function for the first time, I encountered a roadblock while using "Axios". Check out the HTML and JavaScript files below: https://i.sstatic.net/afD41.png HTML (This section allows for inputting values in the "English" and "Japan ...

The button labeled "modify layout" remains unresponsive when activated

Allow me to start by saying that I am not a coding expert. Currently, I am enrolled in a computer science class and have a basic understanding of HTML, CSS, and some Javascript. However, I have encountered a problem that I cannot solve. When I click on th ...

Utilize a JavaScript function on an element that is generated dynamically

I am encountering an issue with my autocomplete function. It works perfectly fine for the input field with the id "field10" that is already created. However, when I dynamically generate new input fields, the function does not seem to work on them. I have ...

Refresh the tally for every item (Attached snippet)

Currently, I'm working on developing a shopping cart application similar to the one found on this website, but utilizing reactjs. Although I've made good progress on the UI aspect, I'm encountering an issue with functionality. index.js: (S ...