| 1168 | ); |
| 1169 | |
| 1170 | const _subscribe: FromSubscribe<TFieldValues> = (props) => |
| 1171 | _subjects.state.subscribe({ |
| 1172 | next: ( |
| 1173 | formState: Partial<FormState<TFieldValues>> & { |
| 1174 | name?: InternalFieldName; |
| 1175 | values?: TFieldValues | undefined; |
| 1176 | type?: EventType; |
| 1177 | }, |
| 1178 | ) => { |
| 1179 | if ( |
| 1180 | shouldSubscribeByName(props.name, formState.name, props.exact) && |
| 1181 | shouldRenderFormState( |
| 1182 | formState, |
| 1183 | (props.formState as ReadFormState) || _proxyFormState, |
| 1184 | _setFormState, |
| 1185 | props.reRenderRoot, |
| 1186 | ) |
| 1187 | ) { |
| 1188 | const snapshot = { ..._formValues } as TFieldValues; |
| 1189 | |
| 1190 | props.callback({ |
| 1191 | values: snapshot, |
| 1192 | ..._formState, |
| 1193 | ...formState, |
| 1194 | defaultValues: |
| 1195 | _defaultValues as FormState<TFieldValues>['defaultValues'], |
| 1196 | }); |
| 1197 | } |
| 1198 | }, |
| 1199 | }).unsubscribe; |
| 1200 | |
| 1201 | const subscribe: UseFormSubscribe<TFieldValues> = (props) => { |
| 1202 | _state.mount = true; |