npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

readact

v0.0.3

Published

React + Flutter ? = Readact ?

Downloads

2

Readme

Redact

A React knockoff ? Probably

A React knockoff with a ui structure similar to flutter ? Definitely

Structure

A component is a class containing 2 major functions :

-Mount
-Render

Mount

Mount is where you initialize the actual node in which the component will be located eg :

mount() {
    Node(this, "div", this.style);
    return this.node;
}

The node helper function will :

-Create a new HTML node
-Take the Class' context and set the class.node variable to the newly create node
-Return the node 

Render

The mount function is the actual place where you define the ui structure of your component

eg :

  render() {
    Return(
      this,
      new Row(
        new Paragraph("Hello", this.state.username),
        new Paragraph("Bye", this.state.username)
      )
    );
  }
}

The return helper function will :

-Reset the content of the parent node of the component
-Mount the component passed as the second parameter
-Render the component passed as the second parameter

Difference between Stateless and Stateful components

A stateful widget will actually update whenever one of it's state changes

(In order to make state handling literally take one line of code you just need to make your component inherit from the Component class and intitialize it with super() in the constructor)

Where a stateless widget will just not update since it doesn't have any state.

eg Stateful :

class MainUI extends Component {
  constructor() {
    super();
  }

  mount() {
    this._state.username = "Sawcce";

    setTimeout(() => {
        this.state.username = 100;
    }, 2000);

    return Node(this, "div", "full-screen");
  }

  render() {
    Return(
      this,
      new Row(
        new Paragraph("Hello", this.state.username),
        new Paragraph("Bye", this.state.username)
      )
    );
  }
}

eg Stateless :

class Text {
    constructor(...args, {type,style}) {
      this.text = args.join(" ");
      this.type = type;
      this.style = style;
    }
  
    mount() {
      Node(this, this.type, this.style);
      return this.node;
    }
  
    render() {
      this.node.innerHTML = this.text;
    }
}

Render your first app with Readact

For this demo I used Rollup to bundle the app into the iife format

(Ended up taking approximately 140 lines of code with nicely formatted code)

const { Component, Node, Return, Builtins } = require("readact");

const Text = Builtins.Text;
const Container = Builtins.Container;

class MainUI extends Component {
  constructor() {
    super();
  }

  mount() {
    this._state.username = "user";

    setTimeout(() => {
      this.state.username = "world";
    }, 2000);

    return Node(this, "div", "full-screen");
  }

  render() {
    Return(
      this,
      new Container(
        {},
        new Text({ type: "p" }, "Hello", this.state.username),
        new Text({ type: "p" }, "wait 10 seconds"),
        new Text({ type: "p" }, "Bye", this.state.username)
      )
    );
  }
}

let UI = new MainUI();

document.body.appendChild(UI.mount());
UI.render();