Home / File/ persistence.js — react Source File

persistence.js — react Source File

Architecture documentation for persistence.js, a javascript file in the react codebase. 4 imports, 1 dependents.

File javascript BabelCompiler Optimization 4 imports 1 dependents 1 classes

Entity Profile

Dependency Diagram

graph LR
  a825b817_81db_b4a3_cf60_e048f10d8d05["persistence.js"]
  14dde3c9_48ef_6e34_3667_978d06aff15d["TestCase.js"]
  a825b817_81db_b4a3_cf60_e048f10d8d05 --> 14dde3c9_48ef_6e34_3667_978d06aff15d
  e1e356f5_b085_dad5_a81f_4b4844381311["TestCase"]
  a825b817_81db_b4a3_cf60_e048f10d8d05 --> e1e356f5_b085_dad5_a81f_4b4844381311
  2f03cb1b_ff7c_7f2b_3a28_70e5f12a2353["hit-box.js"]
  a825b817_81db_b4a3_cf60_e048f10d8d05 --> 2f03cb1b_ff7c_7f2b_3a28_70e5f12a2353
  fc9f3f89_2f8e_1981_9a7a_be6e6b016b4d["HitBox"]
  a825b817_81db_b4a3_cf60_e048f10d8d05 --> fc9f3f89_2f8e_1981_9a7a_be6e6b016b4d
  f8580ab0_af28_a75c_9c9c_5db8c5f3f5f7["index.js"]
  f8580ab0_af28_a75c_9c9c_5db8c5f3f5f7 --> a825b817_81db_b4a3_cf60_e048f10d8d05
  style a825b817_81db_b4a3_cf60_e048f10d8d05 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import TestCase from '../../TestCase';
import HitBox from './hit-box';

const React = window.React;

class Persistence extends React.Component {
  state = {
    persisted: 0,
    pooled: [],
  };

  addPersisted = event => {
    let {persisted, pooled} = this.state;

    event.persist();

    if (event.type === 'mousemove') {
      this.setState({
        persisted: persisted + 1,
        pooled: pooled.filter(e => e !== event),
      });
    }
  };

  addPooled = event => {
    let {pooled} = this.state;

    if (event.type === 'mousemove' && pooled.indexOf(event) === -1) {
      this.setState({pooled: pooled.concat(event)});
    }
  };

  render() {
    const {pooled, persisted} = this.state;

    return (
      <TestCase title="Persistence" description="">
        <TestCase.Steps>
          <li>Mouse over the pooled event box</li>
          <li>Mouse over the persisted event box</li>
        </TestCase.Steps>

        <TestCase.ExpectedResult>
          The pool size should not increase above 1, but reduce to 0 when
          hovering over the persisted region.
        </TestCase.ExpectedResult>

        <h2>Add Pooled Event:</h2>
        <HitBox onMouseMove={this.addPooled} />

        <h2>Add Persisted Event:</h2>
        <HitBox onMouseMove={this.addPersisted} />

        <p>Pool size: {pooled.length}</p>

        <p>Persisted size: {persisted}</p>
      </TestCase>
    );
  }
}

export default Persistence;

Domain

Subdomains

Classes

Frequently Asked Questions

What does persistence.js do?
persistence.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What does persistence.js depend on?
persistence.js imports 4 module(s): HitBox, TestCase, TestCase.js, hit-box.js.
What files import persistence.js?
persistence.js is imported by 1 file(s): index.js.
Where is persistence.js in the architecture?
persistence.js is located at fixtures/dom/src/components/fixtures/event-pooling/persistence.js (domain: BabelCompiler, subdomain: Optimization, directory: fixtures/dom/src/components/fixtures/event-pooling).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free