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

Default AppDelegate.m prevents Cmd+R from reloading app #97

Open
bhb opened this issue Aug 19, 2015 · 4 comments
Open

Default AppDelegate.m prevents Cmd+R from reloading app #97

bhb opened this issue Aug 19, 2015 · 4 comments

Comments

@bhb
Copy link

bhb commented Aug 19, 2015

First off, thanks so much for your work on Ambly. It's really great!

I have followed the instructions here and I noticed that something about the implementation of AppDelegate.m prevents the normal React Native "Cmd+R to reload" behavior from working. I don't believe this is related to the actual REPL set up, since I have a repro that avoids that code.

Repro:

  1. Follow instructions here but replace AppDelegate.m with this code. Note that I've commented out the code related to Clojurescript, but the ABYContextExecutor is still being set as the executorClass.
  2. Make sure you are using React 0.8.0 (in package.json)
  3. Boot the app in the Simulator
  4. Change something in index.ios.js
  5. In the Simulator, hit Cmd+R

Expected: The changes in index.ios.js should appear
Actual: Screen goes blank. If I hit Cmd+R a few times, I get EXC_BAD_ACCESS in RCTContextExecutor.m line 445.

Note that if I comment out this line and repeat the above, things work as expected, so it seems to be some issue with the ABYContextExecutor.

I'm afraid I'm quite new to Obj-C, so I can't see what exactly is going wrong. Please let me know how I can be of assistance.

@mfikes
Copy link
Owner

mfikes commented Aug 19, 2015

@bhb Cmd+R causes a React Native app to reload its JavaScript—thus reflecting changes in index.ios.js by pulling them in, making use of the React Native Packager. The ClojureScript React Native Quick Start page is designed to instead rely on Ambly to push new changes into JavaScriptCore, making use of ClojureScript's ability to dynamically replace code at runtime.

So, with this vision, you would be using something like Om or Reagent, making changes to either function definitions (defn) or the app state (swap!), or simply invoking (require 'foo.ns :reload). The overall strategy would be to eliminate the need for the React Native Packager (see ClojureScript with React Native).

There is a video showing me developing in this style without ever doing Cmd-R.

@bhb
Copy link
Author

bhb commented Aug 20, 2015

Awesome video! I hadn't seen that one yet, but it really does show off the power of REPL-driven-development.

I agree that using the REPL to reload the code via (require ... :reload) is a great workflow. I use that workflow nearly all the time, but I do find myself wanting a "full reload" in some cases. Right now, since Cmd+R does not work, I end up needing to restart the app in these cases. Please correct me if I'm wrong and I don't need to restart for these - I may be missing something.

  1. If I change index.io.js, I need to restart the app to see the changes.
  2. If I change the contents of the init function (AFAICT, this is only called once on app boot), I need to reboot the app to see the changes.
  3. Using (require ... :reload) works for many things, but if I delete a function and re-require, that function is still around in the REPL. That could cause subtle bugs if there is a function that relies on the now-deleted function, so I need to reboot to get a clean state. Granted, the REPL will show the warning "WARNING: Use of undeclared Var" (very handy!), but I can still see subtle errors cropping up here.
  4. If there is an error during the initial render (say, a bug in the the widget component), I need to reboot to continue making changes
  5. If I accidentally hit Cmd+R, I need to reboot to continue making changes.

If I could avoid rebooting the app in these cases, it'd really speed up my development. I was thinking that perhaps Cmd+R could solve these by providing a "full reload" that would throw away the current REPL state and start a new one with a fresh copy of the CLJS. But there may be other solutions I'm not seeing.

@mfikes
Copy link
Owner

mfikes commented Aug 20, 2015

@bhb Your enumeration sounds correct. As it stands now, things are very rough around the corners as you can see.

@bhb
Copy link
Author

bhb commented Aug 20, 2015

@mfikes It's a great tool and I'm more than happy to help smooth out those corners 😄. Unfortunately, I don't yet see the root cause (sorry, my objective-c is weak), but please let me know if I can be of any assistance.

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

No branches or pull requests

2 participants