Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
Aggregate multiple objects as an array and synchronize changes

I start to use a third party <datetime-picker> component that only accept a Date[] of size 2 as its v-model (for a range of time). In my previous codebase, I maintained 2 separate Date objects, i.e. startTime and endTime, and I hope to stick with that.

// in previous codebase (class-based Vue component)
private startTime = new Date();
private endTime = new Date();

// now I must use an array due to the third-party component...
private dateTimeRange = [this.startTime, this.endTime];

Apparently the following won't work, since the reference itself in the array will be overwritten:

<datetime-picker v-model="dateTimeRange" ... />

I want a clean way to propagate changes (issued by the datetime picker component) to the array back to startTime and endTime object.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I would try it like this:

  1. private dateTimeRange = [new Date(), new Date()]; --> to remove the more complicated reference stuff through a "proxy" instance variable.

  2. Use a computed/property accessor to then receive and render both values:

    private get dateRange(): NiceType {
        return {start: this.dateTimeRange[0], end: this.dateTimeRange[0]}
    }
    
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!