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

convert Focus to TypeScript #700

Merged
merged 30 commits into from
Feb 14, 2024
Merged

Conversation

unional
Copy link
Contributor

@unional unional commented Jan 28, 2024

This branch is based on ts1 thus includes all changes in that branch.

This can be merged after #655 is merged.

I am opening this PR now to gather feedbacks.

@unional
Copy link
Contributor Author

unional commented Jan 28, 2024

IMO the addCommands and addMethod should be avoided.
It is likely causing some bugs, especially the focus is a singleton.

return this.supportedCommands.indexOf(cmd) !== -1;
}

async _write_parts(parts, cb) {
async _write_parts(parts: any[], cb: any) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is not used anywhere, remove?

if (this[methodName]) {
const tmp = this[methodName];
this[methodName] = (...args) => {
addMethod(methodName: string, command: string) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method while being used in two places,
the added methods are not being used.

I think this can be removed.

@unional
Copy link
Contributor Author

unional commented Jan 28, 2024

Hi @alexpargon,

I notice that you migrated some code into Device and Serial, etc.

I take a look at the new code. IMO one concern about the new code is its testability.
The code that interacts with external (e.g. serial port) needs to be isolated and most business logic should be extract out of them as much as possible.

You can consider applying Clean Architecture or Hexagonal Architecture

This allows quick check of typescript error without running `yarn make-dev` which is much slower
The conversion will be done in many small PRs,
so that the changes can be merged quickly,
minimizing merge conflicts for the team.
The name does not accurately match behavior.
Suggest fixing it in the future
`w` is the convention I use as I'm lazy.
Feel free to suggest otherwise
the `num2hexstr` usage actually shows that the first param is a string,
and the second param is opional based on the commented console log.

the value is defaults to 0 to better match its intent and passes type check.
to enable further refactoring
that is more inline to the behavior
@alexpargon
Copy link
Contributor

Hey there @unional !

You are right about the new comms block, but it's a change that was required as the new methods of communication require further integration with the Node engine (HID), I have just implemented this feature as is but will better abstract it as soon as we release the Bluetooth capable Bazecor (HID), that will be my next priority because testing is a must and after your efforts, it's getting simpler to write good tests.

@alexpargon alexpargon merged commit f291b89 into Dygmalab:newFocusArch Feb 14, 2024
7 of 10 checks passed
@unional unional deleted the focus2 branch February 14, 2024 20:46
@unional
Copy link
Contributor Author

unional commented Feb 15, 2024

Sounds good. Let me know if there is any area you need help to clean up / redesign / add tests.

I'm even thinking of rewriting kaleidoscope in Rust or Zig. 🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants