589 questions
3
votes
2
answers
155
views
How to handle a computed property on a class?
I have a class used in my VueJS project. I have a function on it which returns a calculated value. If I make this a computed property then it works fine in my VueJS application.
However, Typescript ...
1
vote
1
answer
75
views
Clarification on Computed Properties [closed]
I’m studying TypeScript and came across this pattern:
type Animal = { [key: string]: number };
let Tiger: Animal = { legs: 4, age: 5, tail: 1, eyes :2 };
From what I understand, this allows adding ...
0
votes
0
answers
41
views
Disabling Form Submit Button Vue3
I would like to disable the submit button in my Vue application if the user hasn't entered data in the donationInput input field. I'm sure I'm missing something basic, thanks for your help identifying ...
3
votes
2
answers
3k
views
Binding Angular route params to computed signals
I'm trying to make my code as reactive as possible, switching from explicit route subscription to withcomponentinputbinding.
export class CustomerProfileComponent {
private readonly oms = inject(...
0
votes
1
answer
66
views
Vue Computed Property Returns NaN
I am trying to make a pagination for my Bostorek project. I used computed property to calculate the start index and end index then slice the array of book objects to show the necessary part of that ...
0
votes
1
answer
4k
views
Angular Signals and Computed Properties
I am having a hard time wrapping my head around the concept of Signals and Computed Properties. I have some dummy data, dummyTasks, that is a simple array of task objects, and a selectedUserTasks ...
0
votes
0
answers
205
views
How to avoid recomputations of computed properties with SwiftData's @Query in SwiftUI
With SwiftData's @Query macro, I get an array of model items. Then, I use a computed property to group the items. The computed property is used twice in my view and is therefore also computed twice. ...
1
vote
1
answer
360
views
Vue3/Nuxt3 computed property reactivity issue with objects
I am struggling for days with this problem and I didn't find any solution even on the internet. The problem is that I have a computed property with a getter and a setter but its setter is not being ...
0
votes
2
answers
50
views
Why component does not hide after change computed property in Vue 3?
I migrate from Vue 2 to Vue 3 code. And I have a problem with computed properies.
html:
<div id="cartStatePopupApp" v-if="isShow"> <!-- v-show="isShow" does not ...
0
votes
1
answer
508
views
Are there any issues/concerns with assigning computed values to a ref property in Vue?
I'm reviewing some Vue code where the developer has assigned a computed value to a ref property. I've never seen this done before, and although it works, it seems odd to me.
Are there any potential ...
0
votes
0
answers
52
views
Avoiding style-mismatch with computed value
My goal is to render a list of elements randomly placed inside a grid.
I tried to achieve this with the cue-computed property. But unfortunately I'm always getting the error:
- rendered on server: ...
0
votes
1
answer
252
views
Useing v-data-table with 'how-select' and 'return-object' dosen't work correctly
Im trying to use Vue3, Vuetify v-data-table component.Without 'return-object' all works fine, im getting id, but i want to get user objects. So the problem is when i click on select all checkbox first ...
1
vote
2
answers
2k
views
Using <number | null> or <number | undefined> in computed() or signals() doesn't work correctly when the value is 0
I'm trying to use singals and computed in my new Angular project, but I'm running into a problem.
I have a computed value, which contains an id, which is a number. This id will be set by user ...
-1
votes
1
answer
221
views
Cannot override mutable property with read-only property that is a var
I am trying to mock CMMotionManager for unit testing. Here is my abbreviated code:
protocol XMotionManager {
var isDeviceMotionAvailable: Bool { get }
var deviceMotionUpdateInterval: ...
0
votes
1
answer
78
views
Is it perfectly correct that this computed property will work like a "pointer" in current Swift?
Have a data source singleton with
class hugestuff ..{
var dataSources: [String: ThingWithIncrediblyLargeArrays] ..
var currentThing: String
}
ThingWithIncrediblyLargeArrays is indeed a ...
2
votes
0
answers
285
views
Upgrading to vue 3.4+ causes useRoute to be undefined inside computed
I have code like this. It generates tabs object for my components
export function generateRouterTabs (tabs?: RouteRecordRaw[] | undefined, tabsName?: string): {
name: string
tabs: IRouterTab[]
} {
...
0
votes
1
answer
36
views
Why I am still seeing the Navbar on /dashboard page?
<Navbar v-if="showNavbar" />
const showNavbar = computed(() =>
route.name !== 'dashboard' &&
route.name !== 'dashboard_home' &&
route.name !== 'display' &...
0
votes
0
answers
119
views
Computed field inside a vue-multiselect v-model?
I am trying to build a multiselect component to nicely display tags in my app.
I receive an objectTags parameter form the parent component, but this field needs to be slightly refactored to be ...
-2
votes
1
answer
78
views
Computed property with a subscripted struct
I have a struct ExampleStruct with a custom subscript. The struct data are a fixed private dictionary, value. The structure has one element Sum that is essentially a summation of the the other ...
1
vote
2
answers
770
views
Why do we need to use `.value` inside a template for a function that returns computed ref
I have a function that returns a ComputedRef like below
// a computed ref function
const publishedBooksMessage = () => computed(() => {
return books.length > 0 ? 'Yes' : 'No'
})
To access ...
0
votes
1
answer
632
views
recompute of the computed property
Good day, please tell me, is it possible to somehow change the behavior of Computed Property?
What is happening here: we show a list of transactions that are dynamically grouped by dates
import ...
0
votes
1
answer
257
views
Load value in ref only when requested in Vue
In my Vue project, I have a ref variable that contains some data loaded from a DB. As a reference, it lives inside a Pinia's setup store.
My goal is to load the value only when requested by user, and ...
1
vote
1
answer
936
views
Create an @State variable based on a Swiftui @Query
I have a SwiftData model and I want to use it with @Query that gets created when the app starts. And then I want to base an @State variable on that @Query variable.
Like this (this is what I am ...
0
votes
1
answer
182
views
Object property won't infer union type created from keyof typeof computed properties
If I create a union type from the keys of an object, I can pass that type around perfectly, as long as the keys are regular strings. But if I use computed properties as keys for the object, ...
-1
votes
2
answers
109
views
How can i map a computed list property in nhibernate
My model contais the following:
public virtual DateTime LastSessionDate { get; set; }
public virtual List<double> Values { get; set; }
Values should be selected from other tables in a custom ...
1
vote
1
answer
125
views
For-in loop doesn't update my main view realtime
I'm quite new to SwiftUI, and I have the following problem. I have a for in loop inside a computed property, that doesn't update my view realtime, but only when the user interacts with another part of ...
3
votes
1
answer
6k
views
using props in computed (vue)
I have this simple 2 component vue app : (nuxt, composition api and ts)
Parent :
<template>
<input type="text" v-model="txt">
<Child :txt="txt">&...
0
votes
2
answers
259
views
How to compute a getter in vue?
I'm expecting to display a computed getter property, but VSC gives me the error "Expected to return a value in 'features' computed property." Even though I'm returnng a true value in getter ...
1
vote
1
answer
1k
views
Error writing a computed value, but I do not write any
I set up a flag foundInBrowser that informs me whether the entry 'aaa' is present in localStorage. Clicking on an input toggle adds/removes the entry, which in turn automatically updates the flag:
<...
-1
votes
1
answer
879
views
Swift: Computed Property - call function when value changed [duplicate]
I have need of a variable that retains the selected index into an array of objects.
I need to make a function call whenever this index changes.
I had thought that computed properties were the way to ...
3
votes
1
answer
889
views
Vue 3 Using computed object to get image info works until I render the value in template, then becomes NaN
I have an app that displays image arrays. Before the image is displayed I need to adjust cropping based upon the image dimensions. When I load the image in a vue child component, I use a computed ...
1
vote
1
answer
893
views
Why Vue Can't Find Variable When Render Computed Property In Setup Script To Template
I am migrating to Vue SFC and have problem using computed property.
With the following code, I want to create two rows, and the visibility of the bottom row (the content row) can be toggled by ...
0
votes
2
answers
464
views
Vue - show loader while computed property being computed
EDIT - Found that sorting is quick, real issue is performance of rendering huge list, so already answered
pls explain to me, why this does nothing:
I have array of thousands of items, there is a ...
1
vote
1
answer
465
views
vuejs - good practices when using getters and/or computed properties
I love vue.js and I definitely love computed properties and VueX getters. But I have come to a point where I am not sure if the way I am using them might have some drawbacks in terms of performance.
...
0
votes
0
answers
17
views
How to organize a Vuex vizualizing data project architecture when repeating the component twice?
I’d like to know how to build the Vuejs project architecture.
At the start I’m fetching some object array in the template, passing it to the component as a computed getter.
Next, I’m filtering the ...
0
votes
0
answers
342
views
Mikro ORM Virtual entity not being present in service
I have the following NestJS route set up:
@Get(':id')
async getUserInfo(@Param('id') id: string) {
const res = await this.userService.findOneByField(id);
console.log(res);
return res;
...
0
votes
1
answer
175
views
Swift can lazy, get and didSet together
Can we do get and didSet together with lazy keyword. I have an array it fetch data from database (get) and another thing when that array will modify i will call delegate to reload data in didSet.
Its ...
0
votes
1
answer
324
views
computed property declared using val vs using var
I have a question about the difference between the following 2 ways to create a computed property for class in kotlin.
for the code below, doesn't it break what val is meant for, i.e. a val variable ...
1
vote
1
answer
9k
views
Vue3/Pinia computed from storeToRefs
I have a situation where I need to create a computed property from a pinia store getter -
import { computed} from 'vue'
import { storeToRefs } from 'pinia'
import {useMyStore} from './../stores/...
-2
votes
2
answers
138
views
Computed property with arguments works but not a suggested way to do it in vuejs? So what are other available options?
I have a component with v-for on list and I want to check if the component is checked or not whenever there is change in the list and update the checked state.
// This works but not the suggested way ...
2
votes
2
answers
862
views
Vue 3 watch function not updating
i'm trying to update a variable on the status of a HTMLInputElement, but the watch method doesn't react on a change from the input field.
const input = ref<HTMLInputElement | null>(null)
const ...
1
vote
1
answer
1k
views
Is it possible in VUE3 to use v-model as a computed property?
For example:
<MyComponent v-model="thisComputed" />
Where thisComputed is a computed property.
I do not know if it is possible. If is, then how?
0
votes
2
answers
2k
views
(Nuxt 3) Computed property from Pinia store doesn't affect the template
I have some pinia stores, like this:
export const common = defineStore('common', {
state: () => ({
banner: null,
...
}),
getters: {
hasBanner(state) {
return !!state.banner
...
1
vote
0
answers
28
views
computed properties circumvent typing in TypeScript? [duplicate]
I found an issue with incorrect typings in our codebase that TypeScript provided no warnings for at all. I managed to narrow it down to a usage of computed properties. In the example function, we want ...
1
vote
0
answers
226
views
How project computed properties to SQL in EF Core?
How can EF Core project computed properties to SQL instead of calculating them on the client side?
public enum OrderType
{
Normal,
Special,
}
public class Order
{
public int ...
0
votes
1
answer
234
views
mapState with TypeScript is enforcing me to use watch on my Vue component state properties
I am trying to use mapState in my TypeScripted written Vue component.
As advised here: How to use mapState function in typescript syntax when using vuex?
I am doing this in order to achieve it:
<...
0
votes
1
answer
194
views
Sorting array coming from computed property, in a method also sorts the original array (that comes from the computed property)
Im building a vue application for quizzes, I want to display the all the previous results of the person that has taken the quiz. For that I fetch the results from my backend and then pass them to the &...
1
vote
2
answers
454
views
Get updated time information from momentjs in vuejs without refreshing the page?
I have a table where I display information about a site. One of these information is the last time data was refreshed.
On the top of the table, I would like to add an icon that appears only if the ...
0
votes
1
answer
44
views
[Vue warn]: Error in render: "TypeError: _vm.stepProgression is not a function"
I'm creating a stepper component with a v-for loop, which currently works without an issues:
<li
v-for="(step, index) in stepper"
:key="step.id"
class="goals-...
0
votes
3
answers
461
views
How can I use a computed property to change the color of a text pill depending on the word using vue composition api?
I have a pill shape that say's either Production or Development. I want the background color to be different depending on if it is production or development. I've done this before with option api, but ...