schotime / cerebralts Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Thanks for a super interesting talk on TypeScript support and the work you have done @schotime!
The talk is here: https://www.youtube.com/watch?v=xMUxCH5uCWY
Here is a short summary, note that API is just temporary to explore, this will be part of further discussions:
context
used in actions, now called helpers.js
in this repointerface ExtProps {
itemId: string
}
connect<ExtProps>()
.with(({state, props, signal}) => ({
// All gives suggestions and errors if wrong usage
foo: state(s => s.foo),
// Dynamic
item: state(s => s.items[0], props(p => p.itemId)),
// Signal
clicked: signal(s => s.clicked)
})
.to(function Comp (props) {
props.foo // Understands what props are actually here
})
chainWithNoInput(x => x
.seq(addItem)
.parallel(p => p
.seq(async ({ props, http }) => {
let results = await http.get<any>("https://api.flickr.com/services/rest/?&method=flickr.people.getPublicPhotos&format=json&api_key=6f93d9bd5fef5831ec592f0b527fdeff&user_id=9395899@N08");
return { flickies: results.result }
})
.seq(async ({ props, http }) => {
let results = await http.get<Countries[]>("https://restcountries.eu/rest/v2/regionalbloc/eu");
return { countries: results.result[0].flag }
})
)
.seq(({ props, helper }) => { console.log("ehh?", props, helper); })
.seqPath(pathTest)
.withPaths({
success: y => y.seq(({ props }) => { console.log("success", props.newTitleResult) }),
error: y => y.seq(({ props }) => { console.log("error", props.newTitleResult) })
})
);
Signals understands their payloads, outputs from actions, paths necessary etc. Basically you get a ton of help making sure you are doing it right.
function addItem({ props, helper, http }: MyContext<{}>): Output {
helper.state(x => x.items).unshift(helper.state(x => x.newItemTitle).get());
return {
newTitle: helper.state(x => x.newItemTitle).get()
}
}
I will make a comment on suggested progress to iterate on this work. Thanks a bunch again @schotime , this is very awesome stuff :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.