v7.3.0 to v8.0.0
Esta página aún no está disponible en tu idioma.
This guide will help you migrate your project from Reactter v7.3.0 to v8.0.0. The new version introduces several enhancements, breaking changes, and fixes to improve stability, performance, and developer experience. Below, we’ll walk you through the necessary steps to update your codebase.
By following this guide, you should be able to successfully migrate your project to Reactter v8.0.0. If you encounter any issues, refer to the official documentation or report them as an issue on Github.
1. Overview of Changes
Enhancements
- Add Reactter devtools extension.
- Add
Rt.addObserverandRt.removeObservermethods to manage the observers. - Add
RtStateObserverclass to monitor the lifecycle of state(onStateCreated,onStateBound,onStateUnbound,onStateUpdatedandonStateDisposed). - Add
RtDependencyObserverclass to monitor the lifecycle of dependency(onDependencyRegistered,onDependencyCreated,onDependencyMounted,onDependencyUnmounted,onDependencyDeleted,onDependencyUnregisteredandonDependencyFailed). - Add
Rt.initializeLoggerto initialize the Reactter logger. - Add
Rt.initializeDevToolsto initialize the devtools for observing the states and dependencies. - Add
debugLabelanddebugInfoto states and hooks to get info for debugging. - Add
RtContextMixinmixin to provide access to theRtinstance. - Add
RtStateabstract class to implement the base logic of the state. - Add
Rt.registerStatemethod to create a new state. - Add
Rt.getRefAtto get the reference of dependency created. - Add
initHookmethod toRtHookto call when hook is created. - Add
cancelmethod toUseAsyncStateto cancel current method. - Update
batchanduntrackedmethods to support asynchronous callbacks. - Enhance event handling and notifier logic for improved stability and performance.
- Enhance state management and error handling.
- Add dependency
modetoRtComponent. - Enhance dependency management to ensure to re-build when is detected changes while building.
Breakings
- Remove
Reactter, useRtinstead. - Remove
ReactterStateImplandRtStateImpl, useRtStateinstead. - Replace
UseAsyncStateStatus.standbytoUseAsyncStateStatus.idle. - Rename
DispatchEffecttoAutoDispatchEffect. - Move
asyncFunctionto the first parameter ofUseAsyncStateandUseAsyncState.withArg. - Remove
Rt.isRegistered, useRt.isActiveinstead. - Remove
Rt.getInstanceManageMode, useRt.getDependencyModeinstead. - Remove
InstanceManageMode, useDependencyModeinstead. - Remove
Lifecycle.initialized, useLifecycle.createdinstead. - Remove
Lifecycle.destroyed, useLifecycle.deletedinstead. - Replace
LifecycleObservertoRtDependencyLifecycle. - Remove
LifecycleObserver.onInitialized, useRtDependencyLifecycle.onCreatedinstead. - Remove
ReactterInstanceandReactterDependency, useRtDependencyRefinstead. - Remove
ReactterHook, useRtHookinstead. - Remove
ReactterInterface, useRtInterfaceinstead. - Remove
RtState.refresh, useRtState.notifyinstead. - Remove
UseInstance, useUseDependencyinstead. - Remove
ReactterAction, useRtActioninstead. - Remove
ReactterActionCallable, useRtActionCallableinstead. - Remove
MemoInterceptors, useMultiMemoInterceptorinstead. - Remove
AsyncMemoSafe, useMemoSafeAsyncInterceptorinstead. - Remove
TemporaryCacheMemo, useMemoTemporaryCacheInterceptorinstead. - Remove
MemoInterceptorWrapper, useMemoWrapperInterceptorinstead. - Remove
Obj. - Remove
initproperty fromRtProvider, useRtProvider.initinstead. - Remove
ReactterComponent, useRtComponentinstead. - Remove
ReactterConsumer, useRtConsumerinstead. - Remove
ReactterProvider, useRtProviderinstead. - Remove
ReactterProviders, useRtMultiProviderinstead. - Remove
ReactterScope, useRtScopeinstead. - Remove
ReactterWatcher, useRtSignalWatcherinstead. - Remove
ReactterDependencyNotFoundException, useRtDependencyNotFoundExceptioninstead. - Remove
ReactterScopeNotFoundException, useRtScopeNotFoundExceptioninstead.
Fixes
- Fix bug in
UseEffectcausing dependencies to not be unwatched. - Fix to show the correct dependency mode in the logger of the
Rt.registermethod. - Fix nested
Rt.batchmethod to work correctly. - Add error handling listeners and continue to next listeners in
Notifierclass. - Fix to propagate state param to
boundInstance. - Remove listeners correctly from single-use listeners and handle null cases.
2. Implement the changes
-
Replace all occurrences of
ReactterwithRt.Reactter.create(...);Rt.create(...);ReactterProvider(...);RtProvider(...); -
If you’re using
ReactterStateImplorRtStateImpl, migrate toRtState.class MyState extendsReactterStateImpl{class MyState extends RtState<MyState> {// Implementation} -
Replace
UseAsyncStateStatus.standbywithUseAsyncStateStatus.idle.UseAsyncStateStatus.standby;UseAsyncStateStatus.idle; -
Replace
DispatchEffectwithAutoDispatchEffect.class MyClass withDispatchEffect{class MyClass with AutoDispatchEffect {// Implementation} -
Move
asyncFunctionto the first parameter ofUseAsyncStateandUseAsyncState.withArg.final uAsyncState = UseAsyncState(initialValue, asyncFunction);final uAsyncState = UseAsyncState(asyncFunction, initialValue);final uAsyncStateWithArg = UseAsyncState.withArg(initialValue, asyncFunction);final uAsyncStateWithArg = UseAsyncState.withArg(asyncFunction, initialValue); -
Replace
Rt.isRegisteredwithRt.isActive.Rt.isRegistered(instance);Rt.isActive(instance); -
Replace
Rt.getInstanceManageModewithRt.getDependencyMode.Rt.getInstanceManageMode(instance);Rt.getDependencyMode(instance); -
Replace
RtState.refreshwithRtState.notify.state.refresh();state.notify(); -
Replace
UseInstancewithUseDependency.final uDependency =UseInstance<MyDependency>();final uDependency = UseDependency<MyDependency>(); -
Replace deprecated
Lifecycleenum values with their new counterparts.Lifecycle.initialized;Lifecycle.created;Lifecycle.destroyed;Lifecycle.deleted; -
Replace
LifecycleObserverwithRtDependencyLifecycle.class MyClass extendsLifecycleObserver{class MyClass extends RtDependencyLifecycle {// Implementation} -
Replace
LifecycleObserver.onInitializedwithRtDependencyLifecycle.onCreated.class MyClass extendsLifecycleObserver{voidonInitialized() {class MyClass extends RtDependencyLifecycle {void onCreated() {// Implementation}} -
Replace
MemoInterceptorswithMultiMemoInterceptor.final memo = Memo(computeValue,MemoInterceptors([MultiMemoInterceptor([// Interceptors]),); -
Replace
AsyncMemoSafewithMemoSafeAsyncInterceptor.final memo = Memo(computeValue,AsyncMemoSafe(),MemoSafeAsyncInterceptor(),); -
Replace
TemporaryCacheMemowithMemoTemporaryCacheInterceptor.final memo = Memo(computeValue,TemporaryCacheMemo(...),MemoTemporaryCacheInterceptor(...),); -
Replace
MemoInterceptorWrapperwithMemoWrapperInterceptor.final memo = Memo(computeValue,MemoInterceptorWrapper(...),MemoWrapperInterceptor(...),); -
Replace
initproperty withRtProvider.initconstructor.RtProvider(init: true,RtProvider.init(...); -
Replace
ReactterProvidersorRtProviderswithRtMultiProvider.RtProviders(...)RtMultiProvider(...) -
Replace
ReactterWatcherwithRtSignalWatcher.ReactterWatcher(...)RtSignalWatcher(...)
3. Verify Your Code
After making the above changes, thoroughly test your application to ensure everything works as expected. Pay special attention to:
- State and dependency lifecycles.
- Event handling and notifier logic.
- Debugging and logging outputs.