34 - Parameter Check Events

by steen_hansen

HTML

<!DOCTYPE html><meta charset="utf-8" />
<title>34 Parameter Check Events</title>



<div id='js-div' style="width:52%">
  <a href='https://github.com/steenhansen/type-czech'  target="_blank" class='git-hub'>GitHub Package</a>
  <div id='js-code'>the javascript</div>
</div>

<div id="the-explanation" style="width:48%">
  <div class='an-explantion'>34 - Parameter Check Events</div>
  <div id='explanation-text'>
    <br>

  To enable testing of function parameters without having to watch and display the Console, TypeCzech
has events that can signal errors. This is referring to the code below. The example to the left
is accessing the browser tab.

<ul>
  <li>
    <b>onStart</b> - event runs when TypeCzech starts (green)
  </li>
  <li>
  <b>onCheck</b> - event executes every time a parameter check function is called (blue)
  </li>
  <li>
  <b>onError</b> - event is run when TypeCzech finds an error 
  </li>
</ul>

To write custom events pass in an object with 'onStart', 'onCheck', and 'onError' keys 
refering to functions to run accordingly.
<pre>
  CUSTOM_COLORS = {
  backBlinkUp: (back_color) => {
    document.body.style.background = back_color
    setTimeout(() => { document.body.style.background = 'white' }, 100)
  },
  onStart: () => CUSTOM_COLORS.backBlink('green'),
  onCheck: () => CUSTOM_COLORS.backBlink('blue'),
  onError: () => CUSTOM_COLORS.backBlink('red')
}

type_czech = TypeCzech(CUSTOM_COLORS, 'LOG-ERRORS')
</pre>
<br>

The above example can be attained with the default event object as below.

<pre>   type_czech = TypeCzech('LOG-ERRORS', TypeCzech().TYPE_CZECH_EVENTS)  </pre>


The example to the left changes the <b>tab title</b> on running checks to be 'checks=2: 1=errors'.
The variable check_error_count is injected with check and error count values by TypeCzech.

<br><br>


  </div>


  <div id="console-log" >
    <div class='a-title'>Console Output</div>
    <div id='log-text'></div>
    <br>
  </div>

  <br><br>






<!--           ...