Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

use forall instead of Void for empty queries, messages, inputs #80

Closed
srghma opened this issue Apr 5, 2020 · 1 comment
Closed

use forall instead of Void for empty queries, messages, inputs #80

srghma opened this issue Apr 5, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@srghma
Copy link
Contributor

srghma commented Apr 5, 2020

from #65

it's also possible to use forall like

-- approach is used here 
-- https://github.com/purescript-halogen/purescript-halogen/blob/bb715fe5c06ba3048f4d8b377ec842cd8cf37833/examples/higher-order-components/src/Harness.purs#L43
-- https://github.com/purescript-halogen/purescript-halogen/blob/bb715fe5c06ba3048f4d8b377ec842cd8cf37833/examples/components-inputs/src/Container.purs#L39

simpleChildComponent :: forall query input messages . H.Component HH.HTML query () input messages Aff

-- and render using `unit` for values and `absurd` or `const unit` for functions

let index = unit -- or some integer
let input = unit -- or some datatype. On first render passed to `initialState` and to `receive` on subsequent renders if `input` is changed
let messageHandler = absurd -- or `Just <<< HandlePanelMessage`
HH.slot _proxy index simpleChildComponent input messageHandler

instead of

type MyQuery = Const Void
type MyInput = Void
type MyMessages = Void
simpleChildComponent :: H.Component HH.HTML MyQuery () MyInput MyMessages Aff
@JordanMartinez JordanMartinez added the enhancement New feature or request label Apr 5, 2020
@JordanMartinez
Copy link
Owner

This tip should be added to the 'Various Tips and Tricks' file: https://github.com/JordanMartinez/learn-halogen/blob/latestRelease/src/08-Going-Deeper/06-Various-Tips-and-Tricks.md

srghma added a commit to srghma/learn-halogen that referenced this issue Apr 6, 2020
srghma added a commit to srghma/learn-halogen that referenced this issue Apr 6, 2020
JordanMartinez added a commit that referenced this issue Apr 6, 2020
feat(#80): use forall instead of Void for empty queries, messages, inputs -> add documentation
@srghma srghma closed this as completed Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants