Coder Social home page Coder Social logo

jsnanigans / blac Goto Github PK

View Code? Open in Web Editor NEW
34.0 6.0 2.0 3.47 MB

BLoC pattern for react.

Home Page: https://blac-docs.vercel.app

License: MIT License

HTML 0.88% TypeScript 98.11% JavaScript 1.01%
bloc-pattern rxjs bloc observer-pattern typescript react reactjs state-management

blac's People

Contributors

gokturkdev avatar jsnanigans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

blac's Issues

Add the ability of Cubits and Blocs to have complex interface states

Hello,

My builds are failing when I try to have interfaces or classes as the state value in a cubit or a Bloc, not sure if I'm doing something wrong or if it is the expected behavior:

Doesn't work:

import { Cubit } from "blac";

export interface Test {
  amount: number;
}

export default class GlobalAppStateCubit extends Cubit<Test> {
  public readonly addNewState = (event: Test): void => {
    this.emit(event);
  };
}

Works successfully:

import { Cubit } from "blac";

export interface Test {
  amount: number;
}

export default class GlobalAppStateCubit extends Cubit<string> {
  public readonly addNewState = (event: string): void => {
    this.emit(event);
  };
}

Add the ability to yield multiple state to a stream in mapEventToState like in Flutter

This package is great, but imo it's missing the critical part which is add multiple state to a stream, would this be possible to make? or is there a limitation in typescript?

Kind of like this

        this.mapEventToState = (event: MyEvent, emit: Emitter) => {
            switch (event) {
                case MyEvent.specificEvent:
                    emit(new Loading());
                    final result = await myPromise();
                    emit(new Loaded());
            }
        }

Webpack failing to compile the library (Gatsby - React project)

Hi, first of all, I want to thank you for this great work. ๐Ÿบ ๐Ÿบ

I was able to try the library out on a create react app and It worked really well. I also tried to test it on a gatsby-react project, and webpack failed to compile it.

I had to do this to get the library working (Import directly from the source and not from the built files):

import { BlocReact } from "bloc-react/src/lib";

I also was thinking that you could split this library into two different libraries, one for the core bloc clases (Bloc&Cubit), and one for the React utilities to use the core ones. Since the business logic should have nothing to do with the framework we use, we could use your core bloc classes in a Vue project, or imagine that we created an app with the bloc pattern in React, but for any reason we had to change to Vue, the impact would be much less if all the business logic has nothing to do with the framework we used for the UI. There are plenty of examples of MVP architecture that has the same business logic for 2 different implementations. Let me know what you think, and again thanks for all your work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.