Home Code The Existential Function · React Native

The Existential Function · React Native

by TM

At Facebook, accessing deeply nested values in data structures fetched with GraphQL can be tedious and verbose. There is a need for a solution that simplifies this process while maintaining language semantics and encouraging type safety with Flow. To address this, Facebook has introduced an existential function called idx. The idx function takes two arguments: a value (typically an object or array) and a function that accesses a nested value on it. The function will try-catch errors that result from accessing properties on null or undefined and return null or undefined accordingly. To improve performance and handle specific types of errors, a Babel plugin has been created that transforms the idx invocation into a conditional expression. Additionally, a custom Flow type declaration has been added to enable proper type-checking during traversal on nullable properties. The idx function, Babel plugin, and Flow declaration are available on GitHub and can be installed using the idx and babel-plugin-idx npm packages.

Meta Data: {“keywords”:”Facebook, GraphQL, nested values, idx, Babel plugin, Flow”}

Source link

You may also like

Leave a Comment

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
-
00:00
00:00
Update Required Flash plugin
-
00:00
00:00