Commit Graph

5 Commits

Author SHA1 Message Date
Valentin Shergin 887ba8f044 Fabric: Support for State in Element<>
Summary:
Before this change the Element<> API didn't allow to specify state objects and crashed during instantiation of non-null states.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D19816358

fbshipit-source-id: 95ba5e03ea98c0260593462146e8523c95245e2b
2020-02-10 12:43:26 -08:00
Valentin Shergin b39c75f20e Fabric: Element<> now returns (and accepts) mutable (non const) shared pointers
Summary:
It makes perfect sense because `Builder` builds totally new shadow trees, so those are not sealed or used by anyone yet.
Assigning it to const shared pointer will do logical sealing (and it does not requires const-cast).
Fewer const-casts in the code, fewer bugs.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D19596284

fbshipit-source-id: 75d1c706034958ba7e4bc80a68af75a57c46eb6f
2020-01-30 19:45:39 -08:00
Samuel Susla 142c66f341 Create ShadowNodeFamily inside ComponentDescriptor
Summary:
Changelog: [internal]

1. Creates `ShadowNodeFamily` inside `ComponentDescriptor`.
2. As a side effect of this, we no longer need `ComponentDescriptor::createEventEmitter` so it is removed.

This is a step in order to merge `StateCoordinator` into `ShadowNodeFamily` and use it as target for state updates.

Reviewed By: shergin

Differential Revision: D19514906

fbshipit-source-id: 04ad3c621886be56925acd76f9b35a09d8c5e15a
2020-01-28 09:32:53 -08:00
Samuel Susla 7f79b46bad Initialise ShadowNodeFamily before ShadowNode is created
Summary:
Changelog: [internal]

1. Use `ShadowNode::Shared` instead of `SharedShadowNode`.
2. Initialise `ShadowNodeFamily` before `ShadowNode`.

Why?
This is a step in order to merge `StateCoordinator` into `ShadowNodeFamily` and use it as target for state updates.

Reviewed By: shergin

Differential Revision: D19471399

fbshipit-source-id: 2f67901c901349d238c711f9eeaadb19fe7c1110
2020-01-28 09:32:53 -08:00
Valentin Shergin 6a1438c044 Fabric: Element<>, a declarative way to describe a component hierarchy
Summary:
`Element` is an abstraction layer that allows describing component hierarchy in a declarative way. Creating `Element`s themself does not create a component tree (aka `ShadowNode` tree) but describes some hierarchical structure that might be used to build an actual component tree (similar to XML Elements).

`Element<>` provides some basic type-safety guarantees: all modifications of element objects require using objects (such as Props or State) of compatible type.

For now, the only useful application of that is building tests.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D19512392

fbshipit-source-id: eb0711c2a537865fa5454dbede53412a135058cf
2020-01-22 11:05:42 -08:00