-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Deprecate DraftEntity before removing #790
Deprecate DraftEntity before removing #790
Conversation
I want to tag @johanneslumpe but it doesn't seem to be letting me. But since he did the work originally to migrate us to the new API, would be good to get perspective on this. |
2138d8d
to
3eb0b13
Compare
@flarnie I'm not sure I agree with the new signature of the functions, where The downside of having this intermediate deprecation phase in general is that it nullifies the gains of the original change, since the problem with entity changes not triggering a content state update will persist. |
@johanneslumpe you are right that this version won't actually give the benefits of the API change. That's why I hope to release the fully migrated version quickly after releasing this. Version 0.10.0 -> warns when you use the old API, but doesn't have benefits of new API yet Because we have many and varied uses of Draft.js internally, it would be almost impossible to migrate all of them to the new API in one swoop. So updating to a version of Draft that doesn't support the old API would probably not happen, and I think we would fall out of sync with the open source version. Other folks using Draft will also find it easier to migrate this way too. And it lets us quickly release the other bug fixes that are present on master currently. If we want Also - did we consider making the entity strategy arguments an object instead of three separate parameters? Three or more starts to get to be too many imo, and what if we want to add more in the future? |
3eb0b13
to
1f4b0e4
Compare
@flarnie The reasoning for the order of arguments is the "callback last" convention. I agree that having a lot of arguments on a function call is not desirable and we could potentially move to an object here, if we don't see performance issues with it. |
The tests and flow are passing on my local machine. Looking into why they are failing in CI. |
It looks like the failing tests are unrelated and are happening on all recent PRs. Opened an issue and will look into it more tomorrow. |
A previous PR had completely removed 'DraftEntity' the module and moved control over entities into ContentState.[1] This changed several public APIs of Draft.js in a non-backwards compabible way. [1]: facebookarchive#376 To make it easier to migrate multiple use cases to the new Draft.js API, and because the transition is too complex for a simple codemod, we are releasing a version that supports both the new and the old API and then later releasing a version that breaks the old API completely. In order to renew support for the old API while also supporting the new API, this PR - restores the DraftEntity module and associated tests/mocks - calls into DraftEntity methods under the hood of the new API We tried to leave as much of the new API code in place and unchanged as possible, so that things will be easier when we are fully removing DraftEntity and switching to the new approach. Next steps: - A PR to add warnings and comments about the deprecation of the old API - Add this, the warnings, and other recent PRs to 0.10.0 alpha version - Add documentation about migrating from deprecated to new API - Release 0.10.0; support both APIs - Make PR that basically undoes this one, moving entity control into ContentState, and release that as version 0.11.0, with warning that it no longer supports the deprecated API.
1f4b0e4
to
5ba4775
Compare
@johanneslumpe what would you think of doing the full change to the entity strategy arguments in 0.11.0, and at that point either putting the Hoping to get more feedback on this before landing - @hellendag or @spicyj any thoughts? |
@flarnie so basically reverting this whole PR and then just converting the args to an object? Seems reasonable to me. At that point we probably should change all public apis which have multiple arguments in order to not have a mix of config objects and plain arguments. Thoughts on that? |
@johanneslumpe You have a point that if we make the multiple args an object here, we would want to do that everywhere. In that case I'm biased towards the smaller amount of change to the API, and I'd rather just change the order of the arguments to put the callback last at that time. I wasn't familiar with that convention, but there is a reference to it in the node.js style guide. Seems reasonable. |
I'm going to land this since I have some of the follow-up work ready, and want to make a new PR with that. Happy to continue conversation about this API change process. I think this is cool though since @johanneslumpe has given some feedback and I talked to @hellendag about it a while ago. |
A previous PR had completely removed 'DraftEntity' the module and moved control over entities into ContentState.[1] This changed several public APIs of Draft.js in a non-backwards compabible way. [1]: facebookarchive#376 To make it easier to migrate multiple use cases to the new Draft.js API, and because the transition is too complex for a simple codemod, we are releasing a version that supports both the new and the old API and then later releasing a version that breaks the old API completely. In order to renew support for the old API while also supporting the new API, this PR - restores the DraftEntity module and associated tests/mocks - calls into DraftEntity methods under the hood of the new API We tried to leave as much of the new API code in place and unchanged as possible, so that things will be easier when we are fully removing DraftEntity and switching to the new approach. Next steps: - A PR to add warnings and comments about the deprecation of the old API - Add this, the warnings, and other recent PRs to 0.10.0 alpha version - Add documentation about migrating from deprecated to new API - Release 0.10.0; support both APIs - Make PR that basically undoes this one, moving entity control into ContentState, and release that as version 0.11.0, with warning that it no longer supports the deprecated API.
Summary
A previous PR had completely removed 'DraftEntity' the module and moved
control over entities into ContentState.1 This changed several public
APIs of Draft.js in a non-backwards compabible way.
To make it easier to migrate multiple use cases to the new Draft.js API,
and because the transition is too complex for a simple codemod, we are
releasing a version that supports both the new and the old API and then
later releasing a version that breaks the old API completely.
In order to renew support for the old API while also supporting the new
API, this PR
We tried to leave as much of the new API code in place and unchanged as
possible, so that things will be easier when we are fully removing
DraftEntity and switching to the new approach.
Test Plan:
This should pass unit tests and I did some manual testing.
Still TODO:
Next steps:
API
ContentState, and release that as version 0.11.0, with warning that
it no longer supports the deprecated API.