Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Joel Kuzmarski
    @leoj3n
    But really I think bind is just outright capable of replacing the proxy function http://stackoverflow.com/a/3349438/906794
    Brad Momberger
    @bmomberger-bitovi
    Function.prototype.bind() does a little bit more than our proxy function is specced for, since you can also pass extra arguments to it that are prepended to the arguments when the original function is called. console.log.bind(console, "a") returns a function that, when called, calls console.log with "a" and then all of the remaining arguments in the call.
    So restricting the use of bind to just the function and the context object, the definition of proxy becomes trivially return fn.bind(context);
    The one thing this doesn't do that $.proxy/can.proxy used to do is take a property key that points to a function on the context object, and proxy to that function, i.e. $.proxy(/foo/, "test")
    Joel Kuzmarski
    @leoj3n
    @bmomberger-bitovi Ah, cool :clap: didn't realize bind would return a function, or use arguments; the code above can then be simply:
          proxy: function(fn, context) {
            return fn.bind(context);
          }
    John Gardner
    @Sinjhin
    Ahh, yeah. What I was working with looked more like return fn.bind(context, arguments);. Guess I didn't need the arguments param.
    Thanks for the explanation and g'Night.
    John Gardner
    @Sinjhin
    Hmm, looks like that actually doesn't properly get arguments passed and does not pass the test. Maybe we should take a quick look tomorrow Brad.
    Joel Kuzmarski
    @leoj3n
    Bad traffic but very close.
    Joel Kuzmarski
    @leoj3n
    Thanks for the opportunity to train Justin. Wishing everyone safe travels home; see you around the 'net.
    John Gardner
    @Sinjhin
    It was great meeting you. See you around!
    Joel Kuzmarski
    @leoj3n
    Some good code to try analyzing with the tools above:
    var Animal = function(){
      this.offspring = [];
    }
    var Dog = function(){};
    Dog.prototype = new Animal();
    this.dog1 = new Dog();
    this.pup1 = new Dog();
    this.dog2 = new Dog();
    this.pup2 = new Dog();
    this.dog1.offspring.push(this.pup1);
    this.dog2.offspring.push(this.pup2);
    this.q1 = this.dog1.offspring[1]; // -> ?
    this.q2 = this.dog2.offspring[1]; // -> ?
    Joel Kuzmarski
    @leoj3n
    Taylor Savage, project manager for Polymer, on server-side rendering and use of monolithic JavaScript meta-platforms (as opposed to the web-platform itself): https://youtu.be/fFF2Yup2dMM (he denounces SSR at 4:00 minutes in).
    Gregg Roemhildt
    @roemhildtg
    Hey bitovi-devs, just wanted to give a big thanks to you for the various bits of advice, training, and awesome frameworks, I have finally got my first canjs app built and working. For the curious, here it is, I'd love feedback if you see anything
    Juan Orozco
    @Macrofig
    Yey! That's awesome @roemhildtg !
    Mohamed Cherif Bouchelaghem
    @cherifGsoul
    hi folks, is it ok to implement valueOf method for custom objects?
    Gregg Roemhildt
    @roemhildtg
    @Macrofig Thanks! Learning canjs has been an overall positive experience, and I'm pretty excited to start using the new app.
    Justin Meyer
    @justinbmeyer
    Please take our training session time survey: https://twitter.com/canjs/status/771026512057434112
    Justin Meyer
    @justinbmeyer
    about to start another mini training: https://www.youtube.com/watch?v=4zIWIMDa490
    Justin Meyer
    @justinbmeyer
    var obj = {subject: "JavaScript"};
        var subject = obj.subject;
        Object.defineProperty(obj,"subject",{
            get: function(){
                return subject;
            },
            set: function(){
                debugger;
            }
        });
      // target = {}
      // o1 = {foo:"bar", zed: "ted"}
      // o2 = {}
      // extend(target, [o1, o2])
      // target //-> {0: o1, 1: o2, length: 2}
      $.extend = function(target, source) {
          for( var prop in source ) {
              target[prop] = source[prop];
          }
          return target;
      };
    Justin Meyer
    @justinbmeyer
        isArray: function(obj) {
            return Object.prototype.toString.call(obj) === "[object Array]";
        },
    Justin Meyer
    @justinbmeyer
    <!DOCTYPE html>
    <html>
    <head>
    <meta name="description" content="CanJS 3.4 - File Navigator - Beginner - START">
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width">
      <title>JS Bin</title>
    
    </head>
    <body>
      <!--
      <span>root</span>
      <ul>
        <li class='file'>📝 <span>cats.png</span></li>
        <li class='file'>📝 <span>dogs.jpg</span></li>
        <li class='folder'>📁 <span>empty folder</span></li>
        <li class='folder hasChildren'>📁 <span>folder with files</span></li>
        <li class='folder hasChildren'>
          📁 <span>folder loading files </span>
          <div class="loading">Loading</div>
        </li>
        <li class='folder hasChildren'>
          📁 <span>opened folder</span>
          <ul>
            <li class='file'>📝 <span>file1.png</span></li>
            <li class='file'>📝 <span>file2.jpg</span></li>
          </ul>
        </li>
      </ul>-->
    
    <script type="text/stache" id="entities-template">
    {{<entityChildren}}
      <ul>
      {{#each this.children}}
          <li class="{{type}} {{#if hasChildren}}hasChildren{{/if}}">
            {{#eq type 'file'}}
              📝 <span>{{name}}</span>
            {{else}}
              📁 <span>{{name}}</span>
            {{/eq}}
            {{>entityChildren .}}
          </li>
        {{/each}}
      </ul>
    {{/entityChildren}}
    
    <span>{{name}}</span>
    {{>entityChildren .}}
    </script>
    
    <script src="//unpkg.com/can/dist/global/can.all.js"></script>
    
    <script>
    
    var entityId = 1;
    
    var makeEntities = function(parentId, depth){
      if(depth > 5) {
        return [];
      }
    
      var entitiesCount = can.fixture.rand(6);
    
      var entities = [];
    
      for(var i = 0 ;  i< entitiesCount; i++) {
    
        // The id for this entity
        var id = ""+(entityId++),
            // If the entity is a folder or file
            isFolder = Math.random() > 0.3,
            // The children for this folder.
            children = isFolder ? makeEntities(id, depth+1) : [];
    
        var entity = {
          id: id,
          name: (isFolder ? "Folder" : "File")+" "+id,
          parentId: parentId,
          type: (isFolder ? "folder" : "file"),
          hasChildren: children.length ? true : false
        };
        entities.push(entity);
        if(isFolder) {
          entity.children = children;
        }
    
      }
      return entities;
    };
    
    var rootEntityData = {
      id: "0",
      name: "ROOT/", 
      hasChildren: true,
      type: "folder",
      children: makeEntities("0", 0)
    };
    </script>
    </body>
    </html>
    var template = can.stache.from("entities-template");
    
    var frag = template(rootEntityData);
    
    document.body.appendChild(frag);
    vijayvishy
    @vijayvishy
    @justinbmeyer do you have the link of 2.3 version of todomvc ?
    conleymon
    @conleymon
    Hi, I was wondering if anyone can help clear something up. Does it harm proto-lookup optimizations to add/delete properties from an object in a prototype chain after instantiation of an object object inheriting from it?
    or is there a difference between reassigning the proto pointer and modifying properties on the prototype object, as far as lookup optimizations are concerned?
    Justin Meyer
    @justinbmeyer
    reassigning proto is much worse
    delete can de-opt a single function, proto reassignment can de-opt many functions
    Justin Meyer
    @justinbmeyer
    @/all hey, CanJS 4.0 is out! It's latest on hacker news if you want to upvote :-) https://news.ycombinator.com/newest
    Justin Meyer
    @justinbmeyer
    @/all I'm going to walk through building a rich text editor on a live stream today: https://www.youtube.com/watch?v=EpG1Wzn5by8
    Justin Meyer
    @justinbmeyer
    @/all We created new training material here: https://www.bitovi.com/academy/