Autoload blogposts on the blog page
This commit is contained in:
parent
90f176019a
commit
449f76cb30
|
@ -80,5 +80,4 @@ view state =
|
|||
div
|
||||
[]
|
||||
[ h1 [] [ text state.status ]
|
||||
, button [ onClick (const RequestPosts), id_ "requestbutton", className "hidden" ] [ text "Fetch posts" ]
|
||||
, div [ className "row" ] $ map post state.posts ]
|
||||
|
|
|
@ -28,12 +28,17 @@ init =
|
|||
, bistate: BlogIndex.init }
|
||||
|
||||
update :: Action -> State -> EffModel State Action (ajax :: AJAX, dom :: DOM)
|
||||
update (PageView route) state = noEffects $ state { route = route }
|
||||
update (PageView route) state = routeEffects route $ state { route = route }
|
||||
update (BIChild action) state = BlogIndex.update action state.bistate
|
||||
# mapState (state { bistate = _ })
|
||||
# mapEffects BIChild
|
||||
update (Child action) state = noEffects $ state { count = Counter.update action state.count }
|
||||
|
||||
routeEffects :: Route -> State -> EffModel State Action (dom :: DOM, ajax :: AJAX)
|
||||
routeEffects BlogIndex state = { state: state
|
||||
, effects: [ pure BlogIndex.RequestPosts ] } # mapEffects BIChild
|
||||
routeEffects _ state = noEffects $ state
|
||||
|
||||
view :: State -> Html Action
|
||||
view state =
|
||||
div
|
||||
|
|
|
@ -14,30 +14,5 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
<script>
|
||||
// Forgive me
|
||||
function eventFire(el, etype){
|
||||
if (el.fireEvent) {
|
||||
el.fireEvent('on' + etype);
|
||||
} else {
|
||||
var evObj = document.createEvent('Events');
|
||||
evObj.initEvent(etype, true, false);
|
||||
el.dispatchEvent(evObj);
|
||||
}
|
||||
}
|
||||
|
||||
interval = setInterval(function() {
|
||||
e = document.getElementById("requestbutton");
|
||||
if(e != null) {
|
||||
eventFire(e, "click");
|
||||
} else {
|
||||
console.log("Tried so hard been so far")
|
||||
}
|
||||
clearInterval(interval);
|
||||
|
||||
e.style.display = "none";
|
||||
}, 250);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue