SkillAgentSearch skills...

PowerReference

Extension function to make WeakReferences easy

Install / Use

/learn @garretyoder/PowerReference
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

PowerReference

PowerReference makes using WeakReferences cleaner and easier.

Building

PowerReference is hosted on Jitpack. To build it, add jitpack to your sources.

maven { url 'https://jitpack.io' }

Include PowerReference.

dependencies {
  implementation 'com.github.garretyoder:PowerReference:1.0'
}

Usage

Make a reference.

val ref = myObject.asReference()

Get object from your reference.

ref()

The object will be nullable (?) because your WeakReference may have been garbage collected since it's creation. To use it you will have to null check it.

ref()?.let {
  //TODO: do something with the object
}

PowerReference provides a simple extension function to make the above pattern easier, safe. The safe method will work on any object, not just PowerReferences.

ref().safe {
  //TODO: do something with the object
}
View on GitHub
GitHub Stars4
CategoryDevelopment
Updated2y ago
Forks0

Languages

Kotlin

Security Score

55/100

Audited on Dec 20, 2023

No findings