7.x.x - Behaviors #208
swingingtom
started this conversation in
General
Replies: 1 comment
-
API DiscussionIm currently no totally convince about the behavior API implementation. The current implementation seems totally disconnected from components, and leave an orphan Behavior element. AlternativesFrom componentmyBlock.addBehavior( new Behavior(...) ); Where this could be useful as a Any inputs? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In the 7.x.x branch, the concept of
Behaviors
has been launched. But its implementation and API are still unstable. This page is all about making them fast, easy to use, reliable and useful, together.Behavior idea
The idea behind
Behaviors
is that three-mesh-ui could provide some (a lot?) of easy to use 'Behavior' to users.Technical concerns
If any of those are implemented in core, medium-term maintenance would suffer.
If any of those are implemented in core, all users (even without using any behaviors) will have to load more as behaviors will be implemented in core.
Goal
Providing easy to use behavior, without making the core grow exponentially.
Allowing users to build their own behaviors to fit their project.
Context
The perfect example is the
BestFit
, which is a nice feature implemented since 6.x. On the 6.x it is implemented in core, and required core to be adapted to that feature.6.x.x Implementation
core/MeshUIComponent
: L534 + L545 + L552 + L534 + L340core/Block
: L66core/InlineManager
: L104 + L122 + L175 + L225 + L3886.x.x API
If others useful
Behavior
require the same, the core would literally implodes. This is why on 7.x.xBestFit
feature is has been refactored as a Behavior.7.x.x Implementation
No core components has knowledge that bestFit may append
examples/behaviors/size/BestFitBehavior
: The behavior holds any of code required for bestFit sourceBestFitBehavior will add new methods to its subject:
three-mesh-ui/examples/behaviors/size/BestFitBehavior.js
Line 10 in 1c5cb6a
BestFitBehavior will override its subject
parseParams()
method:three-mesh-ui/examples/behaviors/size/BestFitBehavior.js
Lines 40 to 44 in 1c5cb6a
7.x.x API
Existing Behaviors on 7.x.x
Foreseen Behaviors
Beta Was this translation helpful? Give feedback.
All reactions