Questions tagged [computed-properties]

Computed properties are functions declared as property. There are multiple languages supporting computed properties, so please use this tag in combination with tags like [swift], [javascript], etc.

Filter by
Sorted by
Tagged with
0 votes
2 answers
44 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 ...
Nitheesh's user avatar
  • 19.4k
0 votes
1 answer
108 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 ...
bonavii's user avatar
  • 15
0 votes
1 answer
33 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 ...
ALai's user avatar
  • 769
0 votes
1 answer
81 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 ...
user2926337's user avatar
0 votes
1 answer
22 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, ...
ShaneSauce's user avatar
0 votes
2 answers
33 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 ...
jgayer's user avatar
  • 3
1 vote
1 answer
91 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 ...
Capitan_Jack_89's user avatar
1 vote
1 answer
403 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">&...
moxyom's user avatar
  • 13
0 votes
0 answers
10 views

How to compute total time from two separated object keys in Vue js?

I'm expecting to compute total time by subtracting date and time from separated object keys in the data array. Hense I'm having a static start and end date format 'yy-mm-dd' and time format '01:02:30'....
john's user avatar
  • 25
0 votes
2 answers
31 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 ...
john's user avatar
  • 25
1 vote
1 answer
153 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: <...
WoJ's user avatar
  • 27.7k
-1 votes
1 answer
94 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 ...
iOSProgrammingIsFun's user avatar
2 votes
1 answer
256 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 ...
Lloyd Loftus's user avatar
1 vote
1 answer
292 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 ...
Ezon Zhao's user avatar
  • 651
-1 votes
2 answers
150 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 ...
PM_KLS's user avatar
  • 73
0 votes
0 answers
50 views

C# map nested computed properties with AutoMapper

I have two basic entities - Invoice and Items for those invoices. This is the basic structure of my entities: public class InvoiceItem { public string Id { get; set; } public decimal Total { ...
Plamen Michev's user avatar
1 vote
1 answer
83 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. ...
paro-paro's user avatar
0 votes
0 answers
15 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 ...
user avatar
0 votes
0 answers
102 views

How to use composable computed value?

I'm trying to create something like service in Vue3. My app will be embedded in windows native (WinAPI) application which is passing me configuration (api-url and other stuff) in the URL query ...
Neevor's user avatar
  • 1
0 votes
0 answers
123 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; ...
Bowis's user avatar
  • 577
0 votes
1 answer
83 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 ...
Yogesh Patel's user avatar
  • 1,931
0 votes
1 answer
73 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 ...
user3463521's user avatar
1 vote
0 answers
3k 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/...
WillardSolutions's user avatar
-2 votes
2 answers
74 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 ...
Vishal Sagar's user avatar
2 votes
2 answers
486 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 ...
Truut's user avatar
  • 83
1 vote
1 answer
366 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?
Tamás László's user avatar
0 votes
2 answers
920 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 ...
lbloodl's user avatar
1 vote
0 answers
25 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 ...
Nate Glenn's user avatar
  • 6,543
1 vote
0 answers
119 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 ...
Alois's user avatar
  • 391
0 votes
1 answer
115 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: <...
Tom Carmi's user avatar
  • 396
0 votes
1 answer
87 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 &...
Ibrahim's user avatar
  • 161
1 vote
2 answers
179 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 ...
Shinwi's user avatar
  • 139
0 votes
1 answer
34 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-...
Gazillacode's user avatar
0 votes
3 answers
206 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 ...
ironman33's user avatar
0 votes
0 answers
66 views

SwiftUI computed var in custom init of a view error

I want to be able to calculate a variable (nbwin) depending of the attribute "nom_rang1" of the coredata entity "RamiSession". Basically, for each entity "RamiSession" ...
user20587286's user avatar
0 votes
0 answers
162 views

VueJS: Unhandled error during execution, Uncaught TypeError

I have a two problems in Vue during using computed properties. I want use it with filter function to show products with correct price category after click but it is not successfully. In console I see ...
Jakub K's user avatar
0 votes
0 answers
189 views

How to create a custom Circle() property in swiftui

I would like to create a custom circle that I can reuse. (Essentially, I would have one spot to edit the circle's properties. So in the future, it will be easier to update my circle's properties ...
user avatar
0 votes
1 answer
114 views

A coredata computed property used to sort an array of object is not updated. Working when I go from view1 to view2, but not from view 3 to view2

I am still quite new at SwiftUI and I am having trouble to understand why the array that I have created in my model “GameSession”, which is sorted according to a computed variable defined in my second ...
user20587286's user avatar
0 votes
2 answers
122 views

How can a string constant be used as a computed identifier in a union type in TypeScript?

I have the following union type: interface Cell {}; type CellInfo = | { Provisioned: Cell } | { Cloned: Cell }; Is there a way to use a computed property identifier instead of a string literal? ...
Jost's user avatar
  • 199
0 votes
0 answers
29 views

How can I use If-statements for proper and optimal way to filter properties by date and keyword properly without affecting the other filter component

I'm trying to optimize this code, its basically a cycle of ifs that checks if a type of filter is active, I initially started with a basic filter by dates that looks like this: if (this.start_date &...
Christian D'Albano's user avatar
0 votes
0 answers
81 views

Vue js and Laravel problem with computed properties can't save data in database

Iam beginner in vue js and i need help.I'm working on invoice application and i want when select customer to auto fill data properties and i'm using computed properties to get data which i need. I ...
Aleks12's user avatar
  • 23
0 votes
0 answers
56 views

Struggling with typing an object, with computed property keys

I'm struggling to correctly type the endpointMeta object in my project. It contains computed object keys that are related to 2 objects services - contains the names of the services currently known. ...
snbk97's user avatar
  • 45
0 votes
1 answer
436 views

How to operate with only one array in composition API Vue 3

I'm new in vue 3, and I need your help. I created vue app that uses rest API to fetch the data. Also I added the features as filter and search to my application. But when I use filter or search ...
Rahym Charyyev's user avatar
0 votes
1 answer
185 views

SwiftUI: Computed Property from reusable View not working

Using the SwiftUI framework, I created this reusable View (minus styling bells and whistles): struct RatingView: View { let criteria: String @State var rating: Int var body: some View ...
ScottyA's user avatar
  • 192
1 vote
1 answer
297 views

React - how to make properly working computed properties?

I am now trying to make table with checkboxes, and got really irritating problem. I reproduced this problem in this example. I have list of items of format {id, value}. For each item I create div ...
untured's user avatar
  • 107
3 votes
0 answers
304 views

Anyone else having an issue seeing padding in Computed Chrome dev tools?

Not sure if this is a bug or something on my end, but Chrome dev tools appear to have stopped showing some Computed properties, specifically padding. I looked at my settings and all seemed normal. It ...
Ripcord's user avatar
  • 65
-1 votes
1 answer
85 views

Swift: How to insert a getter in computed property to calculate a person's age

I have written the following computed property to calculate the age of the app user: var ageCalc: Int { let calendar: NSCalendar! = NSCalendar(calendarIdentifier: .gregorian) let now = Date() ...
weekendwarrior's user avatar
1 vote
1 answer
1k views

Type 'string' is not assignable to type 'ComputedRef<string>'

I've got this code in my Vue app: What I want to do is change the color property based on the props. I also use computed, because the color property could change outside the component. export default ...
Ballazx's user avatar
  • 451
0 votes
1 answer
372 views

function() is not a function;

I want my function to update the data displayed by a vue chart js each time I click on a button but I get this error: "_vm.chartData is not a function". I use computed properties as told in ...
Guts's user avatar
  • 35
0 votes
1 answer
632 views

Vue store and computed doesnot reactive even with vue set

I have following computed property in my Vue component: computed: { contragent_id: { get() { return appData.getters["basket/contragent_id"]; }, set(value) { ...
Sergei Illarionov's user avatar

1
2 3 4 5
12