万本电子书0元读

万本电子书0元读

顶部广告

ReasonML Quick Start Guide电子书

售       价:¥

1人正在读 | 0人评论 9.8

作       者:Raphael Rafatpanah

出  版  社:Packt Publishing

出版时间:2019-02-28

字       数:18.9万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
A hands on approach to learning ReasonML from the perspective of a web developer. Key Features * Hands on learning by building a real world app shell that includes client-side routing and more. * Understand Reason’s ecosystem including BuckleScript and various npm workflows. * Learn how Reason differs from TypeScript and Flow, and how to use it to make refactoring less stressful. Book Description ReasonML, also known as Reason, is a new syntax and toolchain for OCaml that was created by Facebook and is meant to be approachable for web developers. Although OCaml has several resources, most of them are from the perspective of systems development. This book, alternatively, explores Reason from the perspective of web development. You'll learn how to use Reason to build safer, simpler React applications and why you would want to do so. Reason supports immutability by default, which works quite well in the context of React. In learning Reason, you will also learn about its ecosystem – BuckleScript, JavaScript interoperability, and various npm workflows. We learn by building a real-world app shell, including a client-side router with page transitions, that we can customize for any Reason project. You'll learn how to leverage OCaml's excellent type system to enforce guarantees about business logic, as well as preventing runtime type errors.You'll also see how the type system can help offload concerns that we once had to keep in our heads. We'll explore using CSS-in-Reason, how to use external JSON in Reason, and how to unit-test critical business logic. By the end of the book, you'll understand why Reason is exploding in popularity and will have a solid foundation on which to continue your journey with Reason. What you will learn * Learn why Reason is exploding in popularity and why it's the future of React * Become familiar with Reason's syntax and semantics * Learn about Reason's ecosystem: BuckleScript and JavaScript interoperability * Learn how to build React applications with Reason * Learn how to use Reason's type system as a tool to provide amazing guarantees * Gain a solid foundation on which to continue your journey Who this book is for The target audience of this book is web developers who are somewhat familiar with ReactJS and who want to learn why ReasonML is the future of ReactJS.
目录展开

Title Page

Copyright and Credits

ReasonML Quick Start Guide

About Packt

Why subscribe?

Packt.com

Contributors

About the authors

About the reviewer

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Conventions used

Get in touch

Reviews

Introduction to ReasonML

What is ReasonML?

Why Reason?

Support for immutability and purity

Module system

Type system

Cross-platform

Maintainability

Interoperability

ES2030

Community

The Future of ReactJS

Exploring Reason

Data structures and types

Creating our own types

Pattern matching

Making Invalid States Impossible

Summary

Setting Up a Development Environment

The Reason toolchain

Installing BuckleScript

Editor configuration

Setting up a pure Reason project

The bsconfig.json file

The warnings field

The package-specs field

The suffix field

The sources field

Working with DOM

Setting up a ReasonReact project

Improving the developer experience

Summary

Creating ReasonReact Components

Component creation basics

Component templates

self

Event handlers

unit

JSX

Props

Children

Life cycles

Subscriptions helper

Stateful components

State, action, and reducer

Refactoring

Instance variables

Ref and mutable records

Navigation menu

Bindings

Events

Js.t Object

Adding actions

Inline styles

React ref

Velocity

Client-side routing

Current route

Helper functions

Usage

Summary

BuckleScript, Belt, and Interoperability

Module scope

Data structures

Array

Using the Reason standard library

Using the Belt standard library

Using BuckleScript's built-in JavaScript bindings

Using a custom binding

Using raw JavaScript

List

Recursion

Pipe operators

Using Belt

Option module

List module

make

makeBy

shuffle

take

Deck of cards example

Currying

Uncurried functions

makeByU

JavaScript interoperability

Using JavaScript in Reason

Understanding the [@bs.val] decorator

Understanding the [@bs.scope] decorator

Understanding the [@bs.send] decorator

Understanding the [@bs.module] decorator

Reasonable APIs

BuckleScript documentation

Binding to existing ReactJS components

Importing dependencies

Creating the make functions

Using [@bs.deriving abstract]

Using the components

Summary

Effective ML

Module signatures

Module types

Abstract types

Using module signatures

Phantom types

Polymorphic variants

Would this work with normal variants?

Advanced type system features

Summary

CSS-in-JS (in Reason)

What is CSS-in-JS?

A brief history

Using styled-components

Using [@bs.variadic]

Using bs-css

Trade-offs

Other libraries

Summary

JSON in Reason

Building views

File structure

Updating the router and navigation menu

CustomerType.re

CustomerList.re

Customer.re

Integrating with localStorage

Populating localStorage

DataPureReason.re

Validating JSON strings

Using Js.Json.classify

Writing to localStorage

Using bs-json

Using GraphQL

What is GraphQL?

When using GraphQL, do I need to create JSON decoders?

Summary

Unit Testing in Reason

Testing with Jest

Installation

Our first test

Testing business logic

Reflecting

Summary

Other Books You May Enjoy

Leave a review - let other readers know what you think

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部