Closed bedeoverend closed 7 years ago
Adds in observeQuery which registers a callback that gets called everytime a query's results change. It is to find as observe is to get.
observeQuery
find
observe
get
For example:
function renderPostIndex(response) { let toPostPreview = (item) => ` <a href="?post=${item.path}"> <div>${item.data.preview}</div> </a> `; this.innerHTML = response.items.map(toPostPreview); } function addPost(name, preview) { Simpla.set(`/posts/${name}`, { data: { preview } }); } Simpla.observeQuery({ parent: '/posts' }, renderPostIndex); Simpla.find({ parent: '/posts' }).then(renderPostIndex);
This above snippet would render all posts by making an initial query, and then watching to see if any more posts are added. Calling addPost would add a new post into Simpla, adding a new item post preview onto the page.
addPost
Adds in
observeQuery
which registers a callback that gets called everytime a query's results change. It is tofind
asobserve
is toget
.For example:
This above snippet would render all posts by making an initial query, and then watching to see if any more posts are added. Calling
addPost
would add a new post into Simpla, adding a new item post preview onto the page.