Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

91
Visualizações
the parameters passed in node-schedule job function is overwrite by the later one

I use schedule to create a class named Schedule,the code is below:

import * as schedule from "node-schedule";
import { switchStationExecuteStore } from '../controller/SwitchStation'
export class Schedule {
  executionId: any;
  time: any;
  deviceParams:any
  nodeType: any;
  nodeName: any;
  constructor(time,executionId,nodeName,nodeType,deviceParams) {
    this.time = time
    this.executionId = executionId
    this.deviceParams = deviceParams
    this.nodeName = nodeName
    this.nodeType = nodeType
  }
  startJob() {
    console.log(this.deviceParams.deviceId)
    schedule.scheduleJob(this.time, function (executionId,nodeName,nodeType,deviceParams) {
      switchStationExecuteStore[executionId].toExecuteDevice(nodeName, nodeType, deviceParams)
    }.bind(null,this.executionId,this.nodeName, this.nodeType, this.deviceParams))
  }
}

And in other file, I use the Schedule class,the code is

 const that = this
 const job = new Schedule(cornTime,this.executionId,nodeName, nodeType, deviceParams)
 job.startJob()

when the code will be execte in the sametime and exectue two times with different deviceParams, the later deviceParams will overwrite the first one,so in the toExecuteDevice function I will always get the later value.

I wonder what's wrong in my code? and how can I do to fix it.Thanks so much

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda