Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: modern implementation #107

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

jacobtipp
Copy link

Status

IN DEVELOPMENT

Breaking Changes

YES

Description

Update API to reflect modern v8.x Dart implementation

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • πŸ› οΈ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • βœ… Build configuration change
  • πŸ“ Documentation
  • πŸ—‘οΈ Chore

@jacobtipp jacobtipp changed the title Feat/modern implementation feat: modern implementation Feb 9, 2023
@felangel felangel added the enhancement New feature or request label Feb 10, 2023
@erickjtorres
Copy link
Collaborator

LGTM

erickjtorres
erickjtorres previously approved these changes Feb 10, 2023
better long term support without breaking current build
@jacobtipp
Copy link
Author

LGTM

I changed the node engine compatibility from version 6 to 14. I believe this is why the CI was failing, as it was running node version 10. Most newer packages support node v14+ only nowadays. Also I have marked this pull request as a draft. I still need to add Cubit/Bloc and their respective tests.

@jacobtipp jacobtipp marked this pull request as ready for review February 16, 2023 02:36
@jacobtipp
Copy link
Author

These are some big changes. I've tried to keep the implementation as close as possible to the original with 100% code coverage.

Some things to note related to Typescript, JavaScript, and limitations:

  • Events must be classes. Which means enums can't be used as events. It is discouraged to use enums in Typescript because they aren't native to JavaScript and will require extra code to be compiled to mimic it's behavior at runtime. Using es6 classes for bloc events makes more sense and gives us consistency. Use discriminated unions instead of enums whenever possible.
  • Typescript doesn't have callabale classes. Which means the emitter instance cannot be used as a function. However, in JavaScript, all functions are objects, so I've created a "callable emitter" that simply proxies all calls to the actual emitter instance. This can be seen here

@felangel
Copy link
Owner

These are some big changes. I've tried to keep the implementation as close as possible to the original with 100% code coverage.

Some things to note related to Typescript, JavaScript, and limitations:

  • Events must be classes. Which means enums can't be used as events. It is discouraged to use enums in Typescript because they aren't native to JavaScript and will require extra code to be compiled to mimic it's behavior at runtime. Using es6 classes for bloc events makes more sense and gives us consistency. Use discriminated unions instead of enums whenever possible.
  • Typescript doesn't have callabale classes. Which means the emitter instance cannot be used as a function. However, in JavaScript, all functions are objects, so I've created a "callable emitter" that simply proxies all calls to the actual emitter instance. This can be seen here

Thanks so much for the huge contribution! I’ll make sure to review this within the next few days πŸ™πŸ’―

@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (69e71fe) 100.00% compared to head (2c906df) 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##            master      #107    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files            1         9     +8     
  Lines           33       196   +163     
  Branches         5        12     +7     
==========================================
+ Hits            33       196   +163     
Impacted Files Coverage Ξ”
packages/bloc/lib/src/base.ts 100.00% <100.00%> (ΓΈ)
packages/bloc/lib/src/bloc-observer.ts 100.00% <100.00%> (ΓΈ)
packages/bloc/lib/src/bloc.ts 100.00% <100.00%> (ΓΈ)
packages/bloc/lib/src/change.ts 100.00% <100.00%> (ΓΈ)
packages/bloc/lib/src/cubit.ts 100.00% <100.00%> (ΓΈ)
packages/bloc/lib/src/emitter.ts 100.00% <100.00%> (ΓΈ)
packages/bloc/lib/src/event.ts 100.00% <100.00%> (ΓΈ)
packages/bloc/lib/src/index.ts 100.00% <100.00%> (ΓΈ)

... and 2 files with indirect coverage changes

β˜” View full report in Codecov by Sentry.
πŸ“’ Do you have feedback about the report comment? Let us know in this issue.

jacobtipp added a commit to jacobtipp/bloc-state that referenced this pull request Feb 19, 2023
github-actions bot pushed a commit to jacobtipp/bloc-state that referenced this pull request Feb 19, 2023
# [1.0.0-beta.3](bloc-v1.0.0-beta.2...bloc-v1.0.0-beta.3) (2023-02-19)

### Features

* **bloc:** πŸ’₯ ✨ sync with bloc.js fork ([3912488](3912488))

### BREAKING CHANGES

* **bloc:** sync with felangel/bloc.js#107
github-actions bot pushed a commit to jacobtipp/bloc-state that referenced this pull request Feb 19, 2023
# [1.0.0-beta.2](react-bloc-v1.0.0-beta.1...react-bloc-v1.0.0-beta.2) (2023-02-19)

### Features

* **bloc:** πŸ’₯ ✨ sync with bloc.js fork ([3912488](3912488))

### BREAKING CHANGES

* **bloc:** sync with felangel/bloc.js#107
github-actions bot pushed a commit to jacobtipp/bloc-state that referenced this pull request Feb 19, 2023
# [1.0.0-beta.2](bloc-concurrency-v1.0.0-beta.1...bloc-concurrency-v1.0.0-beta.2) (2023-02-19)

### Features

* **bloc:** πŸ’₯ ✨ sync with bloc.js fork ([3912488](3912488))

### BREAKING CHANGES

* **bloc:** sync with felangel/bloc.js#107
github-actions bot pushed a commit to jacobtipp/bloc-state that referenced this pull request Feb 19, 2023
# [1.0.0-beta.2](bloc-todos-v1.0.0-beta.1...bloc-todos-v1.0.0-beta.2) (2023-02-19)

### Features

* **bloc:** πŸ’₯ ✨ sync with bloc.js fork ([3912488](3912488))

### BREAKING CHANGES

* **bloc:** sync with felangel/bloc.js#107
github-actions bot pushed a commit to jacobtipp/bloc-state that referenced this pull request Feb 19, 2023
# [1.0.0-beta.2](hacker-news-v1.0.0-beta.1...hacker-news-v1.0.0-beta.2) (2023-02-19)

### Features

* **bloc:** πŸ’₯ ✨ sync with bloc.js fork ([3912488](3912488))

### BREAKING CHANGES

* **bloc:** sync with felangel/bloc.js#107
github-actions bot pushed a commit to jacobtipp/bloc-state that referenced this pull request Mar 10, 2023
# 1.0.0-fix-release.1 (2023-03-10)

### Bug Fixes

* **bloc:** πŸ› added State to BlocBaseConfig generic argument ([e0cda85](e0cda85))
* **bloc:** πŸ› change historyLimit to 1 ([359085f](359085f))
* **bloc:** πŸ› rethrow errors caught inside emit ([8d20c83](8d20c83))
* **bloc:** πŸ› rethrow unhandled error from eventHandler ([19cef9f](19cef9f))
* **bloc:** πŸ› switched to vite for bundling ([a9780d5](a9780d5))
* **build:** πŸ› πŸ“¦οΈ set sideEffects flag to false ([8ee593a](8ee593a))
* **state:** πŸ› change property stateName to name ([a360c93](a360c93))
* **state:** πŸ› make immer peer dependency ([4382844](4382844))
* **state:** πŸ› switched to vite for bundling ([a1c7847](a1c7847))

### Features

* **bloc:** ✨ added BlocHistory class for time travel ([14334b1](14334b1))
* **bloc:** ✨ added customizable subject option ([5818057](5818057))
* **bloc:** ✨ added history ([0777c1e](0777c1e))
* **bloc:** ✨ use Subject instead of BehaviourSubject ([ffc0df8](ffc0df8))
* **bloc:** πŸ’₯ ✨ sync with bloc.js fork ([3912488](3912488))
* **ci:** ✨ πŸ‘· ci trigger ([0720886](0720886))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/react-bloc ([f7130a1](f7130a1))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/state ([d19970f](d19970f))
* initial commit [skip-ci] ([904a867](904a867))

### BREAKING CHANGES

* **bloc:** sync with felangel/bloc.js#107
github-actions bot pushed a commit to jacobtipp/bloc-state that referenced this pull request Mar 10, 2023
# 1.0.0-fix-release.1 (2023-03-10)

### Bug Fixes

* **bloc-provider:** πŸ› explicitily accept BlocBase<any> for bloc prop array ([0d75ee2](0d75ee2))
* **bloc:** πŸ› added State to BlocBaseConfig generic argument ([e0cda85](e0cda85))
* **bloc:** πŸ› rethrow errors caught inside emit ([8d20c83](8d20c83))
* **bloc:** πŸ› rethrow unhandled error from eventHandler ([19cef9f](19cef9f))
* **bloc:** πŸ› switched to vite for bundling ([a9780d5](a9780d5))
* **build:** πŸ› πŸ“¦οΈ set sideEffects flag to false ([8ee593a](8ee593a))
* **react-bloc:** πŸ› added memoization to hooks where needed ([a1cfeeb](a1cfeeb))
* **react-bloc:** πŸ› fix path for types in package.json ([8aa5c35](8aa5c35))
* **react-bloc:** πŸ› populate BlocListener with initial state ([bd84382](bd84382))
* **react-bloc:** πŸ› satisfy react-hooks/rules-of-hooks ([08d029a](08d029a))
* **react-bloc:** πŸ› set private to false in package.json ([18fb19c](18fb19c))
* **state:** πŸ› change property stateName to name ([a360c93](a360c93))
* **state:** πŸ› make immer peer dependency ([4382844](4382844))
* **state:** πŸ› switched to vite for bundling ([a1c7847](a1c7847))

### Features

* **bloc:** ✨ added customizable subject option ([5818057](5818057))
* **bloc:** ✨ added history ([0777c1e](0777c1e))
* **bloc:** πŸ’₯ ✨ sync with bloc.js fork ([3912488](3912488))
* **ci:** ✨ πŸ‘· ci trigger ([0720886](0720886))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/react-bloc ([f7130a1](f7130a1))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/state ([d19970f](d19970f))
* initial commit [skip-ci] ([904a867](904a867))
* **react-bloc:** ✨ add useDebugValue ([526fc9b](526fc9b))

### BREAKING CHANGES

* **bloc:** sync with felangel/bloc.js#107
github-actions bot pushed a commit to jacobtipp/bloc-state that referenced this pull request Mar 10, 2023
# 1.0.0-fix-release.1 (2023-03-10)

### Bug Fixes

* **bloc-concurrency:** πŸ› update type definitions path ([2e37905](2e37905))
* **bloc:** πŸ› added State to BlocBaseConfig generic argument ([e0cda85](e0cda85))
* **bloc:** πŸ› rethrow errors caught inside emit ([8d20c83](8d20c83))
* **bloc:** πŸ› rethrow unhandled error from eventHandler ([19cef9f](19cef9f))
* **bloc:** πŸ› switched to vite for bundling ([a9780d5](a9780d5))
* **build:** πŸ› πŸ“¦οΈ set sideEffects flag to false ([8ee593a](8ee593a))
* **state:** πŸ› change property stateName to name ([a360c93](a360c93))
* **state:** πŸ› make immer peer dependency ([4382844](4382844))
* **state:** πŸ› switched to vite for bundling ([a1c7847](a1c7847))

### Features

* **bloc:** ✨ added customizable subject option ([5818057](5818057))
* **bloc:** ✨ added history ([0777c1e](0777c1e))
* **bloc:** πŸ’₯ ✨ sync with bloc.js fork ([3912488](3912488))
* **ci:** ✨ πŸ‘· ci trigger ([0720886](0720886))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/bloc-concurrency ([6d1de94](6d1de94))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/react-bloc ([f7130a1](f7130a1))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/state ([d19970f](d19970f))
* initial commit [skip-ci] ([904a867](904a867))

### BREAKING CHANGES

* **bloc:** sync with felangel/bloc.js#107
github-actions bot pushed a commit to jacobtipp/bloc-state that referenced this pull request Mar 11, 2023
# 1.0.0-fix-publish.1 (2023-03-11)

### Bug Fixes

* **bloc:** πŸ› added State to BlocBaseConfig generic argument ([e0cda85](e0cda85))
* **bloc:** πŸ› change historyLimit to 1 ([359085f](359085f))
* **bloc:** πŸ› rethrow errors caught inside emit ([8d20c83](8d20c83))
* **bloc:** πŸ› rethrow unhandled error from eventHandler ([4c7b3b6](4c7b3b6))
* **bloc:** πŸ› switched to vite for bundling ([a9780d5](a9780d5))
* **bloc:** πŸ› trigger release ([d33d70b](d33d70b))
* **build:** πŸ› πŸ“¦οΈ set sideEffects flag to false ([8ee593a](8ee593a))
* **state:** πŸ› change property stateName to name ([a360c93](a360c93))
* **state:** πŸ› make immer peer dependency ([4382844](4382844))
* **state:** πŸ› switched to vite for bundling ([a1c7847](a1c7847))

### Features

* **bloc:** ✨ added BlocHistory class for time travel ([14334b1](14334b1))
* **bloc:** ✨ added customizable subject option ([5818057](5818057))
* **bloc:** ✨ added history ([0777c1e](0777c1e))
* **bloc:** ✨ use Subject instead of BehaviourSubject ([ffc0df8](ffc0df8))
* **bloc:** πŸ’₯ ✨ sync with bloc.js fork ([3912488](3912488))
* **ci:** ✨ πŸ‘· ci trigger ([0720886](0720886))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/react-bloc ([f7130a1](f7130a1))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/state ([d19970f](d19970f))
* initial commit [skip-ci] ([904a867](904a867))

### BREAKING CHANGES

* **bloc:** sync with felangel/bloc.js#107
github-actions bot pushed a commit to jacobtipp/bloc-state that referenced this pull request Mar 11, 2023
# 1.0.0-fix-publish.1 (2023-03-11)

### Bug Fixes

* **bloc-provider:** πŸ› explicitily accept BlocBase<any> for bloc prop array ([0d75ee2](0d75ee2))
* **bloc:** πŸ› added State to BlocBaseConfig generic argument ([e0cda85](e0cda85))
* **bloc:** πŸ› rethrow errors caught inside emit ([8d20c83](8d20c83))
* **bloc:** πŸ› rethrow unhandled error from eventHandler ([4c7b3b6](4c7b3b6))
* **bloc:** πŸ› switched to vite for bundling ([a9780d5](a9780d5))
* **bloc:** πŸ› trigger release ([d33d70b](d33d70b))
* **build:** πŸ› πŸ“¦οΈ set sideEffects flag to false ([8ee593a](8ee593a))
* **react-bloc:** πŸ› added memoization to hooks where needed ([a1cfeeb](a1cfeeb))
* **react-bloc:** πŸ› fix path for types in package.json ([8aa5c35](8aa5c35))
* **react-bloc:** πŸ› populate BlocListener with initial state ([bd84382](bd84382))
* **react-bloc:** πŸ› satisfy react-hooks/rules-of-hooks ([08d029a](08d029a))
* **react-bloc:** πŸ› set private to false in package.json ([18fb19c](18fb19c))
* **state:** πŸ› change property stateName to name ([a360c93](a360c93))
* **state:** πŸ› make immer peer dependency ([4382844](4382844))
* **state:** πŸ› switched to vite for bundling ([a1c7847](a1c7847))

### Features

* **bloc:** ✨ added customizable subject option ([5818057](5818057))
* **bloc:** ✨ added history ([0777c1e](0777c1e))
* **bloc:** πŸ’₯ ✨ sync with bloc.js fork ([3912488](3912488))
* **ci:** ✨ πŸ‘· ci trigger ([0720886](0720886))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/react-bloc ([f7130a1](f7130a1))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/state ([d19970f](d19970f))
* initial commit [skip-ci] ([904a867](904a867))
* **react-bloc:** ✨ add useDebugValue ([526fc9b](526fc9b))

### BREAKING CHANGES

* **bloc:** sync with felangel/bloc.js#107
github-actions bot pushed a commit to jacobtipp/bloc-state that referenced this pull request Mar 11, 2023
# 1.0.0-fix-publish.1 (2023-03-11)

### Bug Fixes

* **bloc-concurrency:** πŸ› update type definitions path ([2e37905](2e37905))
* **bloc:** πŸ› added State to BlocBaseConfig generic argument ([e0cda85](e0cda85))
* **bloc:** πŸ› rethrow errors caught inside emit ([8d20c83](8d20c83))
* **bloc:** πŸ› rethrow unhandled error from eventHandler ([4c7b3b6](4c7b3b6))
* **bloc:** πŸ› switched to vite for bundling ([a9780d5](a9780d5))
* **bloc:** πŸ› trigger release ([d33d70b](d33d70b))
* **build:** πŸ› πŸ“¦οΈ set sideEffects flag to false ([8ee593a](8ee593a))
* **state:** πŸ› change property stateName to name ([a360c93](a360c93))
* **state:** πŸ› make immer peer dependency ([4382844](4382844))
* **state:** πŸ› switched to vite for bundling ([a1c7847](a1c7847))

### Features

* **bloc:** ✨ added customizable subject option ([5818057](5818057))
* **bloc:** ✨ added history ([0777c1e](0777c1e))
* **bloc:** πŸ’₯ ✨ sync with bloc.js fork ([3912488](3912488))
* **ci:** ✨ πŸ‘· ci trigger ([0720886](0720886))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/bloc-concurrency ([6d1de94](6d1de94))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/react-bloc ([f7130a1](f7130a1))
* **ci:** ✨ πŸ‘· ci trigger for @jacobtipp/state ([d19970f](d19970f))
* initial commit [skip-ci] ([904a867](904a867))

### BREAKING CHANGES

* **bloc:** sync with felangel/bloc.js#107
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants