-
Notifications
You must be signed in to change notification settings - Fork 17
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
Support LiveView.swift #47
Comments
Good idea! We should totally put this in our library. We will probably want to wait for #34 to be wrapped up first before working on this 👍 |
Using the
Unfortunately adding the Probably the best way would be to wrap the code you want to move to //#-live-view-code
import PlaygroundSupport
let page = PlaygroundPage.current
page.liveView = FaceViewController()
//#-end-live-view-code then let the gem parse the file, extract the code between those tags (and remove it from What do you think? |
In the meantime I've implemented the aforementioned solution. I've started from #34 as suggested, so before posting the pull-request it would make sense to merge the other one. I still need to add some tests. IMHO, based on the preview of a small playgroundbook I'm writing on Bézier curves, the experience is improved a lot when the Live View is rendered immediately on page load. |
This makes sense to me 👍 Thanks a lot! |
My proposed implementation was intended let you have a working playground both on macOS and iOS. However it would be only a partial solution as if you want leverage the completely separate LiveView process on Swift Playgrounds on iPad, I don't think there's a solution suitable for both platforms. |
In the sample code provided by Apple called TalkingToTheLiveView, for each page there is a
LiveView.swift
file that contains few lines of codeThose files are located besides
Contents.swift
inside each.playgroundpage
folder.I find them very useful if the reader shouldn't be able to mess with most of the code of the Live View, but instead just interact with it through the PlaygroundSupport Module.
I don't have specific tests but probably the
LiveView.swift
file won't be recompiled each time the editor is updated, to achieve optimal performances.The text was updated successfully, but these errors were encountered: