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
Example: Adding a very basic version of a todo app #311
Conversation
faisalil
commented
Feb 6, 2019
- I am very new to reason, so any suggestions are welcome even if they are minor nits.
- As part of this, I did a workaround to an issue in Input and made the event subscriptions Always instead of OnMount, this breaks having multiple Input fields but this needs to be fixed differently.
- The goal is to make this match the full todo mvc example, however, I wanted to send something out as a start and then take some fixes to Input before continuing with this.
@faisalil - awesome, thank you very much! Can't wait to try this out |
@@ -87,31 +90,36 @@ let make = | |||
*/ | |||
let slots = | |||
React.Hooks.effect( | |||
OnMount, | |||
Always, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch on this issue @faisalil - thanks for investigating & fixing it!
examples/TodoExample.re
Outdated
); | ||
|
||
let createElement = (~children, ~currentFilier, ~onPickingFilter, ()) => | ||
React.element(make(children, currentFilier, onPickingFilter)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think currentFilier
should be currentFilter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Fixed it.
}; | ||
}; | ||
|
||
module FilterSection = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing you might be interested in - @jchavarri and @wokalski are looking at ways to streamline the component creation to a function / remove boiler plate here: briskml/brisk-reconciler#6
Nothing to be changed since we don't have it yet, but would be great to get your feedback on that since you have a fresh perspective!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will be great. I will check this out. Most of the code to create a basic component didn't feel natural. glad you are looking into it.
examples/TodoExample.re
Outdated
| Completed | ||
| NotCompleted; | ||
|
||
let textOfFilter = (filter: filter) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One convention that comes up in OCaml (and that Reason inherited) is a convention of using a type t
with a module, especially if there are functions that use it. So you could potentially refactor this to something like:
module Filter {
type t =
| All
| Completed
| NotCompleted;
let show = (v: t) => switch(v) {
| All => "All"
| Completed => "Completed"
| NotCompleted => "NotCompleted"
};
};
Not something that is strictly necessary, but it's a convention that I found interesting as I start diving into Reason - the ubiquity of a module plus a type t
.
- '1 Module for 1 thing': https://github.com/ostera/reason-design-patterns/blob/master/patterns/1-module-1-thing.md
It's a little bit different than thinking in an OO language - a lot of times the Module will have a core type + functions that operate on that top. So comes up a lot in the standard modules - like there is a Hashtbl.t('a, 'b)
that the Hashtbl module provides functions for: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Hashtbl.html
No changes necessary - just thought you might be interested in this 😎 Nice use of variants for this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very useful. Thanks for sharing. One goal I have in helping here is to ramp up on Reason, so thanks for this.
Just got to play with it a bit! Overall the code looks excellent @faisalil - I just put some minor nits / commentary in, but it looks great. How was your first Reason experience? I took a quick screen grab of testing it out in case anyone else wants to see it: I noticed one bug that I think is a reconciler issue - when I switch between 'Completed' and 'Not Completed' tasks, sometimes the checkbox state doesn't change. The logic in the sample looks correct to me. We could try specifiying a But we can track this separately, too - I do think it's possibly a value not being updated by the reconciler. The only blocker I see is that CI is failing due to formatting - could you try running So cool that you tried it out and built this @faisalil , really appreciate it! |
@bryphe oh no... I should have a couple of fixes coming in the coming days. I hope it'll get fixed! |
Thanks for the comments @bryphe , I will get to addressing the comments and fixing the merge conflicts tomorrow. |
Thanks @faisalil ! I'll publish a new version of the playground (https://www.outrunlabs.com/revery/playground/) once its in! 👍 |
@bryphe , calling
Gives an error : "Error: Unbound value Key.create" I am not sure about the right syntax and I cannot find any documentation on this. |
@bryphe, I am actually liking reason. The startup of the test app is amazing and this kind of perf is always very attractive. |
Change should be ready for final review. |
Ah, looks like this needs to be
Very cool! @jordwalke would be happy to hear this 😄
There are still some challenges with language support - but I believe the best environment at the moment is OSX + VSCode + However, there is a really powerful language tool called Thanks for the feedback and thoughts, @faisalil ! |
* adding todoapp * reformating * Fixing the build issue