Commit Graph

1 Commits

Author SHA1 Message Date
Rishabh Rathod
d6372d0b81
feat: JSObject variable as a state (JSObject variable mutation) (#19926)
Fixes #19653 
Fixes #14568 
Fixes #17199
Fixes #14989

In this PR, we introduce a new feature in JSObject where the `variables`
are now state and widgets are reactive to the change in the variable
value.
- It means that `JSObject.myVar1 = "Hello world"` would show `Hello
world` where ever a binding `{{JSObject.myVar1}}` is used.

Further changes
- JSObject run functionality, executes all the functions in async
evaluation.
    - `executeSyncJS` flow is removed 
-  `resolvedFunctions` state is moved to JSCollection class.
- unEval JSObject value i.e., currentJSCollectionState is moved to
JSCollection class.
- `evalTreeWithChanges` is introduced - A new flow to trigger evaluation
from the worker and send the updated dataTree to mainThread.
- This would open up a new possibility of features in evaluation
mentioned
[here](https://www.notion.so/appsmith/RFC-Dependent-Property-in-Widgets-f3b29ad652b549dd8c49189f48dbbc4b)
- Introduction of `updateDataTreeHandler` to accept new dataTree from
the worker.
## Type of change

- New feature (non-breaking change which adds functionality)

## How Has This Been Tested?

### Jest Test
- `Mutation.test.ts` 
- `JSVariableProxy.test.ts`
-  `removeProxy.test.ts`

### Cypress test
- Mutation with 
   - numbers
   - array
   - object
   - map
   - set

### Test Plan
- https://github.com/appsmithorg/TestSmith/issues/2186

### Issues raised during DP testing

- https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1453275688
- https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1478975487
- https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1482929425
- https://github.com/appsmithorg/appsmith/pull/19926#issuecomment-1486611858

Co-authored-by: Rimil Dey <rimildeyjsr@gmail.com>
Co-authored-by: Rimil Dey <rimil@appsmith.com>
Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
2023-04-07 13:11:36 +05:30