HN user

gcanti

111 karma

giulio.canti@gmail.com

Posts28
Comments40
View on HN
medium.com 9y ago

Slaying a UI Antipattern with Flow

gcanti
2pts0
medium.com 9y ago

Phantom types with Flowtype

gcanti
3pts0
medium.com 9y ago

The Eff monad (Flowtype)

gcanti
1pts0
github.com 10y ago

Show HN: Combining Flow with tcomb to allow for runtime enforced refined types

gcanti
4pts0
github.com 10y ago

Show HN: Babel plugin for static and runtime type checking using Flow and tcomb

gcanti
2pts0
github.com 10y ago

Show HN: Documenting react components using runtime type introspection

gcanti
4pts0
github.com 10y ago

Show HN: Tcomb v2.6 type-checked recursive types for JavaScript

gcanti
8pts0
github.com 10y ago

Show HN: Immutable and type-checked state and actions for Redux

gcanti
20pts2
github.com 11y ago

Show HN: React Native-powered forms generator

gcanti
25pts1
gcanti.github.io 11y ago

Show HN: A compact, flexible, skinnable form library for React.js

gcanti
2pts0
gcanti.github.io 11y ago

Replacing propTypes with type annotations in React 0.13

gcanti
2pts0
github.com 11y ago

Show HN: Assert library for AtScript

gcanti
1pts0
gcanti.github.io 11y ago

Show HN: Tcomb-form – React.js UI library for developing forms writing less code

gcanti
5pts1
github.com 11y ago

React-vdom upgraded to React v0.12.0

gcanti
1pts1
gcanti.github.io 11y ago

Understanding React and reimplementing it from scratch

gcanti
5pts0
gcanti.github.io 11y ago

JavaScript, Types and Sets (Part II) and a Side Note on React.js

gcanti
2pts0
gcanti.github.io 11y ago

Introduction to set theory with JavaScript

gcanti
5pts0
gcanti.github.io 11y ago

Six reasons to define JavaScript constructors with only one argument

gcanti
11pts0
gcanti.github.io 11y ago

JSON API Part 2: validation in Node.js with type combinators

gcanti
2pts0
gcanti.github.io 11y ago

JSON Api deserialization into an object model with tcomb.js

gcanti
6pts0
gcanti.github.io 11y ago

An alternative syntax for React propTypes

gcanti
5pts0
github.com 11y ago

Test your React components like a boss

gcanti
2pts0
gcanti.github.io 11y ago

A JavaScript validation library based on type combinators

gcanti
2pts0
github.com 11y ago

Show HN: A new validation library for JavaScript (React, Backbone integration)

gcanti
8pts0
github.com 11y ago

Fast prototyping: Bootstrap + React.js + debugging support

gcanti
3pts0
gcanti.github.io 11y ago

Show HN: A playground for react-bootstrap with debugging support

gcanti
2pts0
gcanti.github.io 11y ago

What if your domain model could validate the UI for free?

gcanti
27pts7
gcanti.github.io 11y ago

Show HN: Tcomb.js – JavaScript types and combinators

gcanti
2pts0

Hi, shameless plug: another (typed) immutable data structure library, https://github.com/gcanti/tcomb. Main features:

- works with regular objects and arrays - runtime type checks - easy debugging with Chrome DevTools - immutability and immutability helpers - runtime type introspection - easy JSON serialization / deseralization - pattern matching

Also https://github.com/gcanti/redux-tcomb (Immutable and type-checked state and actions for Redux)

I need to be able to asynchronously get data from all kinds of places before I can even think about calling React.renderToString

You can define middlewares, as you would do server-side with expressjs:

    router.route({
      method: 'GET',
      path: '/users/:userId',
      handler: function (ctx) {
        // load user async
        getUser(ctx.params.userId, function (err, user) {
          ctx.user = user;
          ctx.next(); // exec next middleware
        }); 
      }
    });
There is a `demo` folder with a detailed example. The main entry point for the client is here https://github.com/gcanti/tom/blob/master/demo/client.js#L21

I'm also experimenting with "isomorphic" apps. I wrote a router with an expressjs/hapijs like API (middlewares included). The main point is handling the state before choosing the view. The concept is general enough to avoid being tied to React although React makes things easier. Once you have such a router, handling nested views (a la react-router) is a trivial particular case.

Here's my lab https://github.com/gcanti/tom

Hello, I wrote this handy little library for testing purposes: you can extract the vdom from a React component and test it against a JSON with simple tools like assert.deepEqual() and without a real DOM. The extracted vdom has the following type definition:

    type Node = {
      tag: string,
      attrs: object<name, value>,
      children: undefined | null | Node | Array<Node>
    }
If your component handle a private state, you can inject a state to test different configurations.

This is an example of massive use in a form generation library:

https://github.com/gcanti/tcomb-form/blob/master/test/test.j...

Hope it can help you too.

What do you think about vanilla `Object.freeze`? Any drawbacks? Here my considerations at the moment:

Pros:

- you can use native data structures instead of continually wrap / unwrap

- you can use native methods on them (map, filter, ...)

- hence (almost) no interoperability problems with other libraries

- overall your coding style doesn't change so much

- (possible perf gains since the js engine knows the object is frozen? - I really don't know)

- EDIT: 0KB dependency

Cons:

- you must find / write a way to update efficiently

Something I would rather enjoy, would be a carefully, curated list of verified great resources for React, not a random list of everything React.

Discovery is a problem for users and also for authors. I wrote a form library https://github.com/gcanti/tcomb-form but I really don't know how to promote it other than add the `react-component` keyword (for [1] ) and list it on [2].

[1] http://react-components.com/

[2] https://github.com/facebook/react/wiki/Complementary-Tools

AtScript Primer 12 years ago

Another options besides comment-based annotations is property based annotations. Basically provide a library that contains all the possible primitive types that can be checked and functions for composing higher order types.

Shameless plug: I wrote a similar library based on set theory (I'm a mathematician)

https://github.com/gcanti/tcomb

EDIT: and here an article explaining the rationale behind the library

https://gcanti.github.io/2014/09/29/javascript-types-and-set...