Skip to Content

Bound

Binds a class method to its instance.

import { bound } from 'aspectra/utils'
 
class Example {
  private readonly name = 'John'
 
  @bound public greet() {
    console.log(`Hello from ${this.name}`)
  }
}
 
const { greet } = new Example()
greet()
[auto-generated] output:
Hello from John
Last updated on