读书笔记-2019年02月22日

版权声明:本文为博主原创文章,未经博主允许不得转载。[email protected] https://blog.csdn.net/panda_8/article/details/87875798

React.Component

背景知识就是 Components , Props , State and Lifecycle.这四个是·React.Component的基础知识。
This section contains a detailed API reference for the React component class definition. It assumes you’re familiar with fundamental React concepts, such as Components and Props, as well as State and Lifecycle. If you’re not, read them first.

The Component Lifecycle

Each component has several “lifecycle methods” that you can override to run code at particular times in the process. You can use this lifecycle diagram as a cheat sheet. In the list below, commonly used lifecycle methods are marked as bold. The rest of them exist for relatively rare use cases.

Mounting挂载视图的时候生命周期,基本自定义View才会用到get...()

These methods are called in the following order when an instance of a component is being created and inserted into the DOM:

constructor()
static getDerivedStateFromProps()
render()
componentDidMount()

Updating每次setState()被调用的时候,更新生命周期如下,不能深入理解的是我们几乎用不到getSnapshotBeforeUpdate().

An update can be caused by changes to props or state. These methods are called in the following order when a component is being re-rendered:

static getDerivedStateFromProps()
shouldComponentUpdate()
render()
getSnapshotBeforeUpdate()
componentDidUpdate()

Kotlin in Android

便捷的第三方库们

在Android里面Kotlin的引入有共同的方法;
第一步,添加一个项目的dependence,classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"(kotlin_version这个在project的build.gradle文件中定义)。
第二步,module下的gradle里面加上插件和Kotlin标准库依赖。apply plugin: 'kotlin-android',compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"

一个封装了大多是Android便捷操作的库,妈妈再也不担心你要用findById了,代码如飞不是梦。

Anko - 系列 - Anko Commons - 简书

Java 6789们的骚操作

Java8新特性

这篇很棒了:
Java9都快发布了,Java8的十大新特性你了解多少呢? - pkufork - 博客园
总结一下:

  1. Lamda表达式提供了箭头函数。
  2. 接口的默认方法和静态方法,这样就能有类似C++的抽象类概念,再也没有重复代码了。
  3. 方法引用,双冒号方法引用,
    1. 构造器Class::new构造器不能有参数。
    2. 静态方法Class::static_method要求接受一个class类型的参数。
    3. 对任意方法引用Class::method没参数的方法可以这么搞。
    4. 特定对象的方法引用,语法是instance::method。
  4. 重复注解
  5. 扩展了注解的支持,几乎所有都能使用注解,包括局部变量、泛型类、父类与接口的实现,连方法的异常也能添加注解。
  6. Optional空指针异常拜拜
  7. Stream函数式编程风格成为现实。
  8. DateTimeApi
  9. 新的JavaScript引擎Nashorn
  10. Base64

猜你喜欢

转载自blog.csdn.net/panda_8/article/details/87875798