Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental API for forgetting objects/sheet #393

Merged
merged 1 commit into from
Mar 8, 2023

Conversation

AriaMinaei
Copy link
Member

@AriaMinaei AriaMinaei commented Feb 3, 2023

This adds two methods to the transactionAPI that would remove an object or sheet's state from the project's state.

import {getProject} from '@theatre/core'
import studio from '@theare/studio'

const project = getProject('...')
const sheet = project.sheet('...')
const object = sheet.object('...')

// let's say you've already set up prop values for your object and created a sequence in the studio

studio.transaction((api) => {
  // calling this will make it as if you never set values for this object or put it in a sequence
  api.__experimental_forgetObject(object)
  
  // calling this will make it as if you never set values for _any_ object in this sheet, and you never created a sequence either.
  api.__experimental_forgetSheet(sheet)

  // note that if you're calling __experimental_forgetSheet(), then there is no need to call __experimental_forgetObject() in case that object belongs in that sheet.
})

// now if you export the project's state, or do that programmatically, the sheet/object won't be in the exported state:
studio.
createContentOfSaveFile(project.address.projectId) // won't have the sheet/object in it

// note that cmd/ctrl+z will still undo the above operations

@vercel
Copy link

vercel bot commented Feb 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
theatre-playground ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 8, 2023 at 11:59AM (UTC)

@AriaMinaei
Copy link
Member Author

Published an insiders' release as 0.6.1-insiders.7dde8ab

@AriaMinaei
Copy link
Member Author

This might interest @tomorrowevening too.

@tomorrowevening
Copy link
Contributor

I'll experiment with this later with my drag and drop prototype, that dynamically adds sheets / objects and would be a good test for this

@AD2018
Copy link
Contributor

AD2018 commented Feb 3, 2023

Please add some method(detachSheet()) that will hide sheet from outline menu in the top left so people can also hide it from UI after deleting sheet

@AriaMinaei AriaMinaei force-pushed the experimental-forget-api branch from 7dde8ab to 852f12f Compare February 6, 2023 13:56
@AriaMinaei
Copy link
Member Author

/release insiders

@github-actions
Copy link

github-actions bot commented Feb 6, 2023

🎉 Released an insiders' build to npm. Here is how to upgrade:
  • 🚧 This is an insiders' build. It possibly is not stable and may corrupt your data. Always backup your work before upgrading.
  • If you do try this build, welcome aboard, insider 😉. If you're feeling generous, share some feedback here or on #contributing at Discord.
  • 🔼 To upgrade, edit package.json and replace the versions of all @theatre or theatric packages with their new versions:
--- @theatre/core: "old-version",
+++ @theatre/core: "0.6.1-insiders.72222e5",
--- @theatre/studio: "old-version",
+++ @theatre/studio: "0.6.1-insiders.72222e5",
--- @theatre/dataverse: "old-version",
+++ @theatre/dataverse: "0.6.1-insiders.72222e5",
--- @theatre/react: "old-version",
+++ @theatre/react: "0.6.1-insiders.72222e5",
--- @theatre/browser-bundles: "old-version",
+++ @theatre/browser-bundles: "0.6.1-insiders.72222e5",
--- @theatre/r3f: "old-version",
+++ @theatre/r3f: "0.6.1-insiders.72222e5",
--- theatric: "old-version",
+++ theatric: "0.6.1-insiders.72222e5",

All published packages are on npm:

@AriaMinaei AriaMinaei force-pushed the experimental-forget-api branch from 852f12f to 4ba4d2f Compare March 8, 2023 11:57
@AriaMinaei AriaMinaei enabled auto-merge (squash) March 8, 2023 11:57
@AriaMinaei
Copy link
Member Author

@AD2018 sure, will do

@f0nar
Copy link

f0nar commented Oct 4, 2023

@AriaMinaei do you have any updates for removing of sheets from project tree?

@AriaMinaei
Copy link
Member Author

@f0nar This was merged in 0.6.1. Upgrade to that version (well, better latest, so 0.7.0) and you'll have the API described in the top comment.

@f0nar
Copy link

f0nar commented Oct 9, 2023

@AriaMinaei I was asking about functionality like 'detachSheet'

@AriaMinaei
Copy link
Member Author

@f0nar detachSheet() hasn't been implemented yet, but detachObject() is: https://www.theatrejs.com/docs/latest/manual/objects#detaching-objects

Do you specifically need to detach sheets from a project?

@f0nar
Copy link

f0nar commented Oct 9, 2023

Yep. I really need it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants