reflex-frp / reflex

Interactive programs without callbacks or side-effects. Functional Reactive Programming (FRP) uses composable events and time-varying values to describe interactive systems as pure functions. Just like other pure functional code, functional reactive code is easier to get right on the first try, maintain, and reuse.
https://reflex-frp.org
BSD 3-Clause "New" or "Revised" License
1.06k stars 147 forks source link

[suggestion] move Test module into main library #412

Open minimapletinytools opened 4 years ago

minimapletinytools commented 4 years ago

The Test.Run module is useful for testing reflex apps as well.

Exposing this test module encourages more modular design where view/controller is cleanly separated from state. For a new reflex developer, finding information on how to test an app w/out rendering it in reflex-dom was a major challenge. Before discovering this, I forked reflex-basic-host and making my own version which is almost identical to whats in Test.Run https://github.com/pdlla/reflex-basic-host

On the plus side I now completely understand how reflex hosts are built. But I think this information should be easier for new developers to find. TBH I'd like to see this documented in quickref.

Also thanks for making such a great package!

Ericson2314 commented 4 years ago

If it brings in too many extra deps we could perhaps make it a "sub library" in the same package.

minimapletinytools commented 4 years ago

I switched over to copy of this test code for my own stuff and added my own functionality which I think would be very useful for others. Would it be helpful if I made a PR where this module + my additions is moved into the main one?

EDIT: I made a package reflex-test-host that contains my additions.

The main addition was splitting up runApp into getAppFrame which outputs an AppFrame and

tickAppFrame :: (t ~ SpiderTimeline Global, m ~ SpiderHost Global)
       => AppFrame t bIn eIn bOut eOut m
       -> Maybe (These bIn eIn)
       -> m [(bOut, Maybe eOut)]

which allows you to tick/profile each frame individually.

@Ericson2314 doesn't seem like it will bring in any new deps

minimapletinytools commented 3 years ago

created a PR: https://github.com/reflex-frp/reflex/pull/450