-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add placeholder partial and interactive dev pages
- Loading branch information
Mario T. Lanza
committed
May 27, 2024
1 parent
99fdb34
commit 3c034b5
Showing
6 changed files
with
69 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The Interactive Development of Components | ||
|
||
Interactive development makes programming a pleasure. Atomic wants to aid interactivity. | ||
|
||
In any browser where the Atomic `cmd` module is loaded, enter `cmd()` into the console, to access your commands and components. Having imported `reg` from the `cmd` module into your modules, one may have used it to expose various commands and components/signals, beyond the standard library Atomic provides itself (`_`, `$`, and `dom`). Entering `cmd()` exposes into the browser console what modules usually keep private. | ||
|
||
To expose changes happening against signals, append `monitor` to the query string of your web app. | ||
|
||
* `?monitor=*` to monitor everything | ||
* `?monitor=$state,$data` to monitor select signals | ||
* `?nomonitor=$state,$data` to monitor everything but certain signals | ||
|
||
Components are headless, stateful objects which provide input and/or output ports. These ports permit issuing commands and subscribing to events as well as wiring components together. A developer can gradually build up an app while directly and regularly interacting with it before all the right UI affordances are in place. Alternately, he can use this facility to monitor, debug, and/or extend an app. | ||
|
||
This suits the Atomic philosophy. | ||
|
||
Start with a pure, functional core and simulate what the app does. Then, wrap the core with an interactive shell, making it into a useful, side-effect producing component. From a turtles-all-the-way-down perspective, programs can be single components or component hierarchies. Then comes the UI. | ||
|
||
In this way, apps emerge from cores, shells, and UIs. Normally, it's not possible to develop these areas one after the other. One may begin with a functional core and, soon enough, add a shell and/or UI. They are developed one after the other but also, to some extent, in parallel. | ||
|
||
In practice, the shell and UI are usually combined into a single module and not necessarily worth the separation. The separation becomes worthwhile when your component warrants the sophistication of a command bus api, and the extensibility of adding things like decorators and handlers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Placeholder Partial | ||
|
||
Pipelines and partial application are commonplace in functional programs. JavaScript is working toward [an operator](https://github.com/tc39/proposal-pipeline-operator) and [syntax](https://github.com/tc39/proposal-partial-application) but is overdue with its arrival. They can be had, of course, with Babel plugins ([operator](https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator) and [syntax](https://babeljs.io/docs/babel-plugin-proposal-partial-application)), but this necessitates a build step, the very thing Atomic wants to avoid. | ||
|
||
This is ideally what one wants to write: | ||
```js | ||
_.range(10) | ||
|> _.map(_.pipe(_.str("Number ", ?), _.lowerCase), ?) | ||
|> _.join(", ", ?) | ||
|> $.log; | ||
``` | ||
Atomic provides `chain` for writing pipelines: | ||
```js | ||
_.chain(_.range(10), | ||
x => _.map(_.pipe(y => _.str("Number ", y), _.lowerCase), x), | ||
x => _.join(", ", x), | ||
$.log); | ||
``` | ||
It's a good alternative to the pipeline operator, but since it's not [point free](https://en.wikipedia.org/wiki/Tacit_programming) it's downright ugly. | ||
One can use partial, [as underscore does](https://underscorejs.org/#partial), but it's too verbose to be practical for routine use: | ||
```js | ||
_.chain(_.range(10), | ||
_.partial(_.map, _.pipe(_.partial(_.str, "Number ", _), _.lowerCase), _), | ||
_.partial(_.join, ", ", _), | ||
$.log); | ||
``` | ||
If you regularly write in the tacit style, your modules can be [repackaged](/dist/atomic_/) as shadow modules. These modules imbue exported functions with optional partial application via a feature called placeholder partial. | ||
Add a trailing underscore to any folder exposing shadow modules to make them explicit. | ||
With placeholder partial the tacit aesthetic is restored: | ||
```js | ||
_.chain(_.range(10), | ||
_.map(_.pipe(_.str("Number ", _), _.lowerCase), _), | ||
_.join(", ", _), | ||
$.log); | ||
``` | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.