You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just want to say this is not a criticism of the code! It's not unmanageable. Mostly I think it's a fun example for a more functional/reactive style.
First: defining the state
{
inSession: boolean
cardsToReview: Card[],// current card at 0answerRevealed: boolean}
a sketch of the main loop
state.cardsToReview=loadCards();while(state.inSession&&state.cardsToReview.length){awaitrender(state);constcard=state.cardsToReview[0];let[answerRevealed,signal]=awaitshowAnswerOrSkip(card);if(answerRevealed!==state.answerRevealed){state.answerRevealed=answerRevealedawaitrender(state);}signal||=awaitgetResponse(card);updateHistory(card,signal);state.cardsToReview.splice(0,1);// or pass cardsToReview to updateHistorystate.answerRevealed=false;}render(state);
Let me know what you think. My customization stuff coming soon may help motivate the changes.
The text was updated successfully, but these errors were encountered:
I just had a call with @aidam38 and we agreed that I would do a minimally-intrusive refactoring/preparing for the script to be able to be unit-tested so we can make future changes with more confidence.
A more functional style is a huge part of that and I plan to extract some pure functions as a first step (+ add npm).
Maybe we can integrate your ideas after I have put some unit-tests into place so we can be sure that it generally still works?
Happy to chat about possible refactorings.
Just want to say this is not a criticism of the code! It's not unmanageable. Mostly I think it's a fun example for a more functional/reactive style.
First: defining the state
a sketch of the main loop
Let me know what you think. My customization stuff coming soon may help motivate the changes.
The text was updated successfully, but these errors were encountered: