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

riotjs-typed

v1.0.0

Published

a simple wrapper of riotjs+riotcontrol,can be used in both browser and ssr

Downloads

4

Readme

riotjs-typed

a simple wrapper of riotjs+riotcontrol,can be used in both browser and ssr

Introduction

It is quiet sad to opensource this repository. I used riotjs for about a year. It's very useful and very small. But in my workgroup, it is not so welcomed.

More and more people ask me why not use vuejs or react. I know they don't know how to use them or use them as poorly as my English. But I think it is not a good idea to insist on using riotjs in my company.

I turned to preact. In an optimistic way, maybe some guys in my company would like to code my projects not just desert them.

Howerver, that's why I opensouce the code.

There is not so many riotjs-typescript wrappers for both SSR and browsers.

So, if you think it's helpful, just let me know.Well, I don't have too much free time, but I would like to fix some bugs if you find them.

How to

browser

html

    <html>
    ...
    <body>
        <your-tag></your-tag>
    </body>
    ...
    </html>

ts

    const actions = {
        mounted: "mounted"
    };
    
    import { tag, TagCore, Store } from "riot-typed";

    @tag({
        name: "your-tag",
        tmpl: `
        <span>Hello, {content}</span>
        `
    })
    class YourTag extends TagCore {
        onCreate( tag, opts ) {
            // http://riotjs.com/api/#manual-construction
            // it is like the callback
            // and tag refers to this

            tag.content = opts.content;

            tag.on("mount", () => {
                opts.ctrl.trigger(actions.mounted);
            });
        }
    }

    import { Control } from "riot-typed";
    const $ctrl = new Control();

    import { Store } from "riot-typed";
    class MountStore extends Store {
        constructor() {
            this.on(actions.mounted, () => {
                console.log("some tag has been mounted");
            })
        }
    }

    $ctrl.addStore(new MountStore());

    const yourTag = new YourTag($ctrl);

    // mount is just like http://riotjs.com/api/#-riotmountcustomtagselector-opts
    // you dont need to pass customTagSelector
    window.onload = () => yourTag.mount({ content: "world" });
  • TagCore & @tag is used like riot.tag();
  • Control is a wrapper for riotcontrol, like Flux.
  • A control must be passed to a TagCore's constructor, new YourTag($ctrl)
  • A Store is kind like redux's middleware.
  • Control.addStoreis like redux's applyMiddleware

SSR

Using the code above.

server.ts

    app.use('/', (req, res) => {
        const $ctrl = new Control();
        const yourTag = new YourTag($ctrl);
        res.end(`
        <html>
        <body>
        ${yourTag.render({ content: "world in server." })}
        </body>
        </html>`);
    });

Good Luck