@joystick.js/ui

cache.get()

How to use the cache.get() method to get the current value of an existing cache.

Once you have an existing cache, to retrieve the current value, you can utilize the .get() method (defined on the object returned when initializing the cache).

Example Usage

ui/components/player/index.js

import joystick from '@joystick.js/ui';

const Player = joystick.component({
  lifecycle: {
    on_render: () => {
      // NOTE: Logs the current value of the player_state cache.
      console.log(window.player_state.get());
    },
  },
  events: {
    ...
  },
  render: ({ props, state }) => {
    return `
      <div class="player">
        ...
      </div>
    `;
  },
});

export default Player;

API

cache.get() => any
This method does not support any parameters.