Skip to content

jboelen/jLockable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

jLockable

jLockable is an extremly lightweight lockable variable class for javascript.

Usage

Creation

Creating a new lockable is very easy. Simply use the following syntax:

var lockable = new jLockable(<default value>);

  • default value: The value you want the lockable to be initialized with.

Value

To access or set the value of the variable, use the "value" property on the jLockable object.

var currentValue = lockable.value; lockable.value = 5;

  • Note: if the variable is locked, it will not accept / retain a new value until unlocked.

Locking

To lock the variable value, there are two options. The first method, the simplest uses the following syntax:

lockable.Lock(<function: onUnlock>);

  • (Optional) onUnlock: The function you want to have run upon the variable be unlocked.

The second way to lock the value allows for you to specify an amount of time you want it locked for:

lockable.LockFor(<integer: time>, <function: onUnlock>);

  • time: Amount of time in milliseconds you want the variable to be locked for.
  • (Optional) onUnlock: The function you want to have run upon the variable be unlocked.

Unlocking

To unlock the variable value to allow for editing use the following:

lockable.UnLock();

About

Lockable variable class

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors