Skip to content

Refactor: Refactor Status #135

@heineiuo

Description

@heineiuo

Status is just a wrapper for Promise

Current Status:

class Status {

async ok():Promise<boolean> {
    constructor(promise:Promise) {
this.promise  = promise
}

    try {
     await this.promise
     return true
    catch(e){
     return false
   }
 }
}

const status = new Status(promise)
if (await status.ok()) {
   // do stuff
}

refactor:

async function method(){
  let error:void|Error
  try {
      await promise
   } catch(e){
      error = e
   }

   return e
}

if (!(await method())) {
    // do stuff
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions