GithubHelp home page GithubHelp logo

cerebralts's People

Contributors

schotime avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cerebralts's Issues

Discussion summary

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:

  • We are missing type definitions on some providers and modules can not be type defined as there is no constructor
  • Currently app specific type definitions for state and signals can be done at root level of controller
  • You have to configure the context used in actions, now called helpers.js in this repo
  • You can instantiate the controller with these app specific types
  • You can connect to this state and signals in components with:
interface 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
  })
  • Signals are defined using chaining API:
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.

  • Actions access and mutates state by:
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 :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.