Skip to content

Feature: Type: Buffer

Аниса edited this page Sep 9, 2022 · 9 revisions

━ What's the Objective?

Buffers beside serving as cache are also important for simplifying complex modules. Vital.kit reutilizes Class to simulate buffers, thus reducing code redundancy!

━ APIs

ℹ️ Note:

Our extensions are written with backwards compatibility in mind; Expect your previous code to work as usual! However we recommend upgrading to newer syntax.


━ vKit.Buffer() (Shared)

@Objective: Creates a new buffer.
const class: cBuffer = vKit.Buffer(
  string: category // Category of the buffer
)

// Note: Avoid exposing the entire class to another scripts unless needed, otherwise just expose 'cBuffer.public'
cBuffer: {
  public, // Public variables must be appended here
  private, // Private variables must be appended here
  instance  // Instances are stored here
}

━ Methods

━ class.public.addMethod() (Shared)

@Objective: Verifies whether the buffer contains the specified ref.
const bool: state = cBuffer.public.isVoid(
  string: ref
)

━ class.public.fetch() (Shared)

@Objective: Fetches instance from buffer using specified ref.
const instance: cInstance = cBuffer.public.fetch(
  string: ref
)

━ class.public.create() (Shared)

@Objective: Creates a new instance using specified ref.
const instance: cInstance = cBuffer.public.create(
  string: ref
)

━ class.public.destroy() (Shared)

@Objective: Destroys an existing instance using specified ref.
const bool: state = cBuffer.public.destroy(
  string: ref
)

━ instance.destroy() (Shared)

@Objective: Destroys the existing instance.
const bool: state = cInstance.destroy()