WeakReference

Module that implements a weak reference to an object.

ATTENTION: This functionality does not work with classical persistence (--legacy-persistence moc flag).

Usage example: Import from the core package to use this module.

motoko name=import
import WeakReference "mo:core/WeakReference";

type WeakReference<T> = { ref : weakT }

public func allocate<T>(obj : T) : WeakReference<T>

public func get<T>(self : WeakReference<T>) : ?T

public func isLive<T>(self : WeakReference<T>) : Bool