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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tokenyet/react-bloc

v0.3.8

Published

React Components that make it easy to implement the BLoC (Business Logic Component) design pattern. Built to be used with the bloc.js state management package.

Readme


Bloc for React

This package is built to work with bloc.

Bloc Components

This is a fork version of felangel's bloc.js, contains a lot of workflow with dart version.

If you are familiar with dart bloc, this package would be your best friend!

A bundle of formz, useBloc, repository, and a common used action_bloc and search_bloc. These should be indenpendent someday.

Formz example

`tsx import { FormzInput } from '@tokenyet/react-bloc';

export enum NameFieldError { empty, }

export class NameField extends FormzInput<string, NameFieldError> { pure() { super.pure(); this.value = ''; }

dirty(value: string) { super.dirty(value); }

validator(value: string | null): NameFieldError | null { if (value == null || value == '') return NameFieldError.empty; return null; } } `

useBloc example

const [formState, formBloc] = useBloc<
  FormValidationBloc,
  FormValdiationState,
  FormValidationEvent
>(new FormValidationBloc(false));

Repository example (_app.tsx in Nextjs)

      <RepoContext.Provider value={
        new Repositories([
          new UserRepository()
          ...any other repos
        ])}>
      ...
          <ThemeProvider theme={theme}>
            {/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
            <CssBaseline />
            <Component {...pageProps} />
          </ThemeProvider>
      ...
      </RepoContext.Provider>

Action Bloc example

  // extend it to define props and what data will receive
  import { ActionBloc, ActionEvent, ActionState } from '@tokenyet/react-bloc';

  export interface LoginProps {
    name: string;
    picture: string;
    password: string;
  }

  export class LoginActionBloc extends ActionBloc<LoginProps, null> {}
  export class LoginActionEvent extends ActionEvent<LoginProps> {}
  export class LoginActionState extends ActionState<null> {}

  // use it in code
  const router = useRouter();
  const repoContext = useContext(RepoContext);
  const userRepo = repoContext.of<UserRepository>(UserRepository);
  const [signupAcitonState, signupActionBloc] = useBloc<
    LoginActionBloc,
    LoginActionState,
    LoginActionEvent
  >(
    new LoginActionBloc(async ({ name, password, picture }) => {
      await userRepo?.signup({ name, password, picture });

      return {
        value: null,
      };
    })
  );

  React.useEffect(() => {
    if (signupAcitonState.status === FormzStatus.submissionSuccess) {
      router.push('/home');
    }
  }, [signupAcitonState.status]);

Search Bloc

A bit complex, just use CommonSearchBloc, and define your way to fetch data, and call PageEvent or FetchEvent to support Load More or Pagination feature. Might have an example someday.

Maintainers