jsnanigans / blac Goto Github PK
View Code? Open in Web Editor NEWBLoC pattern for react.
Home Page: https://blac-docs.vercel.app
License: MIT License
BLoC pattern for react.
Home Page: https://blac-docs.vercel.app
License: MIT License
I'm getting this error when emit is called from a Cubit.
This repository has a minimal reproduction sample : https://github.com/Rukkaitto/CleanProject
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);
};
}
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());
}
}
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.