Giter VIP home page Giter VIP logo

Comments (4)

yogiben avatar yogiben commented on August 20, 2024

Thanks for your first PR. I will implement this tomorrow.

Out of interest, what's the benefit of grouping your collections?

from meteor-admin.

aldeed avatar aldeed commented on August 20, 2024

It keeps the window object less cluttered on the client, but I only do it in really large apps, and it's not really critical. It's also useful when you're creating the collection in a package and you want to attach everything to a single exported variable. Similar to how Meteor.users is attached to Meteor instead of just Users. You handle the users collection specially, but another package could export in the same way.

from meteor-admin.

yogiben avatar yogiben commented on August 20, 2024

@aldeed Could you share the snippet or method you use for parsing strings with '.' to return JS objects?

from meteor-admin.

aldeed avatar aldeed commented on August 20, 2024
function lookup(obj) {
    var ref = window;
    var arr;
    if (typeof obj === "string") {
      arr = obj.split(".");
      while(arr.length && (ref = ref[arr.shift()]));
      if (!ref) {
        throw new Error(obj + " is not in the window scope");
      }
      return ref;
    }
    return obj;
  }

That takes either the object itself or a string representation of it with dots. If it's an object, just returns it, otherwise lookup based on the string pieces. It's client-specific, though, so if used in server code, you'd have to detect whether client or server, and change that first line to ref = global (I think) on the server.

from meteor-admin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.