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
rebind #42
Comments
I had this usecase just today actually. By removing the following line: And adding I can call |
I'm sorry to let you wait, I have to push some updates, one of them includes the possibility to refresh the binders by user request, I think that would close this issue. I just need a bit of time (very rare thing right now for me) to clean it and push it. |
As a follow up to this; I'm guessing you're redoing a lot of the binders themselves here as well? This like the bo-class binding, or the bo-if need modifying to add or remove elements in either case, not just do the positive effect or nothing? (I'm modifying it myself at the moment for this purpose exactly). |
Probably should; I'm just doing it at work atm and not sure how they'd feel about me doing that. But I'll change it on my own and try submit a PR. |
I also have this use case and suggested #50 . The API could be What do you all think? I'm going to work on this for my own project this week - would others like this api? cc @Pasvaz |
Soon (I think this weekend) I'll publish two new directives, one is |
Perfect, that's exactly what I had in mind. Thanks! Let me know if you can use help either implementing or testing. |
thank you @rileylark, I appreciate it. |
I've got some huge $watches dragging me down and will need to start work on this soon. I'll be happy to offer a PR but don't want to redo work you've already done. @Pasvaz, do you have a branch in progress I can extend? |
Hey, I love the idea of using events, and the idea of one watcher will make a huge appeal to many people. Is this planned for any time soon? Thanks a lot. |
I'll try to push my branch today, I'm sorry I can't do it as soon as I thought but I'm facing some deadlines. |
Hey, no worries, bindonce will save me a ton of time even without this feature. I'd appreciate seeing your branch for this issue even incomplete - I'm sure I'll at least learn about your architecture by seeing where you've started, and maybe I can even help finish the implementation! |
I pushed the branch rebind-debug https://github.com/Pasvaz/bindonce/blob/rebind-debug/bindonce.js , it works but it's still embrional, I need to test it extensively and to rewrite/clean the code. |
@rileylark it would be nice if you and the others could be test the rebind-debug branch extensively in order to evidentiate the bugs or memory leaks so I can change or confirm the way it works. |
Thanks a bunch - I played with it some this weekend and will have some serious time this week. |
Hah, I hadn't seen your last comment when I posted. Yes, I'll be happy to send you some of my tests. Is the new I didn't have angular set up in the same build setup that you have, so in my initial test page I just included it from the CDN. |
feel free to modify the demo as you want or to create new ones, that branch is supposed to be a work in progress so it is quite wild. At the moment, the first approach was to emulate angular and so to destruct and rebuild each bo-directive, the next step will be to improve it and reuse elements instead of removing them in order to speed up the whole process. |
@Pasvaz I just sent you a PR with a simple demo for bo-src and bo-style. I am not sure that $broadcast and $emit are going to be sufficient for my project. I am making a slide editor, with infrequently-changing slides. Each slide is represented twice: once in a long list of all of the previews, and again in the main editor area. These are sibling scopes, and each of my slides should have its own I have an alternative idea to using the $scopes as event busses: a complementary bindonceNotify service that I can inject into any required code. My client code can call bindonceNotify('customUpdateEventName'), and your rebind-on api can register on a back end of the service. That way we can ignore the $scopes altogether, avoid muddying up the $on handlers, and have a kind of private channel for rebind notifications. What do you think? I can submit another PR for this if you think it's a worthwhile direction to explore. |
I went ahead and sketched it out in #60 |
Any further progress on |
@archer96 I've made an Angular fork that does this, it is at: https://github.com/r3m0t/angular.js/tree/digest_limit It is built at: https://github.com/r3m0t/bower-angular tag: An example is at: https://gist.github.com/r3m0t/9271790 Watch out, it works very differently from pasvaz.bindonce. You can use |
guys I'll complete it asap, right now I'm busy dealing with some deadlines. @archer96 could you test the rebind branch, it's not complete but some feedback could surely help. |
Hello, I tried using that branch but there is one tiny "bug" that is annoying. Firstly my code:
here my javsacript code:
Rebind works well when putting
I'd like to use Regards, |
@rajdeepg, please try it now |
Hi Pasvaz, I just tried the latest and no longer getting the 'removeWatcher' error but also not seeing my ng-repeat update it self. Here is the code I am using: In My controller: I am updating the Name field in the item and hoping that it refreshes in my grid but it is not refreshing? Is there something I am doing wrong? If you can share some sample code on how this should work that will be great? Thanks, Raj |
+1 :) Following this interesting feature... |
😄 i'm counting the days… bind once directive is really amazing and having the rebind feature… it could be perfect!! I hope that this could be available soon… |
U know another way to sort of do this is to wrap your bindonce directive inside something else that will change, like a top-level object with infrequent watch triggers. When it does change, all the DOM children are refreshed, even if they are then "static" again after that. |
+1 |
In the meantime - check out this: https://github.com/pcw216/angular-watch-when . Seems like to be a complete solution for that problem! Haven't got time yet to check that in a real app, but looks interesting. |
+1 |
4 similar comments
+1 |
+1 |
+1 |
+1 |
Take a look on this directive http://kent.doddsfamily.us/kcd-angular/#/kcd-recompile |
Here is my interpretation of 'kcd-recompile' directive (it uses angular 1.3 and broadcast events) http://jsbin.com/pigofojogo/2/edit?html,js,output |
Is this feature currently under development? or is it advised to try alternative like kdc-recompile? I tried this latter with Angular 1.3, can't manage to make it work when wrapping an ng-repeat... |
+1 What happen to this? any idea when it will be available? Did anyone succeed with a workaround? |
Well, I'll just recommend you switching to angular 1.3 and to plugins mentioned above, they work perfectly. |
Here is the 0.3.1 rebind-debug branch working for Angular 1.3, i have made a plunk. |
one workaround I was found somewhere: http://jsbin.com/tifukitesu/1/edit?html,js,output |
I'm playing with I've never used bindonce |
how about maintaining a structure similiar to / copy of |
You can use directives which recompile HTML, but use it with small HTML blocks only, or you get page blinking. Let's say you have a list, so you can make:
And if you want to refresh a single row, just use: $scope.$broadcast('refresh-row-' + row_index); |
I cannot. In my case I am manipulating a spreadsheet a-la-Excel. The table is fixed, but all values are dynamically recomputed as the user scrolls. Only when he scrolls I want to recompute all these values. For all the other actions, their watchers are uselessly executed on every digest cycle. However when I actually scroll, all the cells are refreshed, which is way faster currently than recompiling the table. I would bet that the compile phase is most of the time the bottleneck of a |
Maybe I didn't get you, but why you cannot recompile each cell? I mean to put in each cell of your table:
i,j - row and column numbers |
I'm pretty sure it would be about the about the same performances to recompile every cell or all of them at once. And this cannot be faster than just refreshing the text. I have set up a JSfiddle here: http://jsfiddle.net/2tzb11um/1/ Set the one-time binding and change |
Look on this "zero-watchers" example I made:http://jsbin.com/fuzanotaho/1/edit?html,js,output ps "watchers" directive is just helper, do not use it in benchmarks |
Thanks. Now use 50 rows and 50 columns in your example and compare the performances with my jsfiddle using watchers: it is a lot slower. Compiling means rewritting the DOM, vs just changing an attribute/text, shouldn't be a surprise that it is slower. |
Right, it's slow. I believe you need to use a custom directive to render each cell on incoming event: http://jsbin.com/konuzudada/1/edit but now I'm not sure if it's faster |
Just tried 150x50 elements, seems a bit faster, so you can use a service as a data provider for the directive, and broadcast refresh event with some parameters to get data from the service and render it. |
Well for this example that may be ok but, let's be honest, a full jQuery, no-angular alternative would almost feel simpler. I don't want to reinvent angular, i.e. The ideal solution would be to keep the one time bindings of angular 1.3+ ( |
floribon, why don't you use the rebind branch of bindonce? I've put online a version working for Angular 1.3 and an adjustment in the bo-class and bo-if directives. |
shameless 'commercial' ahead I've been tinkering on a continuation of fast-bind[1] and fast-bind[2] for 1.3 and I feel fairly happy with the current state of things. Have a look at bind-notifier if you need to refresh your binds but not recompile the entire DOM node. Usage: <div bind-notifier="{ keyOne:expr1, keyTwo:expr2 }">
<span>{{:keyOne:spanOneExpression}}</span>
<span>{{:keyTwo:spanTwoExpression}}</span>
<span>{{:keyOne:keyTwo:spanThreeExpression}}</span>
</div> Values can also be rebound by broadcasting
note2: |
Is it possible to force refresh of bindonce item?
The text was updated successfully, but these errors were encountered: