Package 

Class Asset

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    
    public class Asset<H extends Object>
     implements AutoCloseable
                        

    Base class for assets managed by a RiveWorker.

    Uses ops to perform operations specific to the asset type.

    Each asset holds a reference to its RiveWorker. When creating assets manually, call close when you no longer need the asset; releasing the worker alone is not enough to purge asset or worker memory while the asset remains open. Closing the asset does not unregister its keys; unregister them explicitly, preferably before calling close.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public class Asset.Companion
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final H handle
    • Method Summary

      Modifier and Type Method Description
      final H getHandle()
      Unit close() Closes this asset and schedules deletion on its Rive worker.
      final Unit register(String key) Register the asset with the given key.
      final Unit unregister(String key) Unregister the asset with the given key.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • close

         Unit close()

        Closes this asset and schedules deletion on its Rive worker.

        Closing does not unregister keys registered through this asset. Prefer to unregister them before closing; unregister remains available afterward while the worker is open. Repeated calls are safe and have no effect after the first call.

      • register

         final Unit register(String key)

        Register the asset with the given key. When Rive fulfills a referenced asset, it will look for an asset registered under that key. The key comes from the zip file created when exporting a Rive file.

        Be sure to unregister the key with unregister when it is no longer needed, preferably before calling close.

        Parameters:
        key - The key to register the asset under.
      • unregister

         final Unit unregister(String key)

        Unregister the asset with the given key.

        This worker-level cleanup does not require the asset handle and remains available after close, provided the owning worker is still open.

        Parameters:
        key - The key to unregister the asset from.