Documentation
Examples
Core

Core

Code

<script>
  import Kronash from '@kronash/core';
 
  const createExample = () => {
    const kronash = new Kronash();
 
    kronash.subscribe((newState) => {
      // you can listen to changes if you need
      console.log(newState);
    });
 
    const createTask = () => {
      const id = nanoid();
 
      const task = kronash.create({
        name: id,
        duration: 1000,
        onTick: (task) => {
          `Task ${task.name} ended`;
        },
      });
 
      task.start();
    };
 
    document
      .querySelector('#example button')
      ?.addEventListener('click', createTask);
  };
</script>
 
<div id="example">
  <button>Create Task</button>
</div>