<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic SplunkJS: What's the difference between get() and getInstance()? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/SplunkJS-What-s-the-difference-between-get-and-getInstance/m-p/159501#M2167</link>
    <description>&lt;P&gt;What is the difference between:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mvc.Components.get(id)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mvc.Components.getInstance(id)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in SplunkJS?&lt;/P&gt;

&lt;P&gt;Is there a reference for Splunk mvc library?&lt;/P&gt;</description>
    <pubDate>Tue, 16 Dec 2014 12:09:57 GMT</pubDate>
    <dc:creator>marco_sulla</dc:creator>
    <dc:date>2014-12-16T12:09:57Z</dc:date>
    <item>
      <title>SplunkJS: What's the difference between get() and getInstance()?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/SplunkJS-What-s-the-difference-between-get-and-getInstance/m-p/159501#M2167</link>
      <description>&lt;P&gt;What is the difference between:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mvc.Components.get(id)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mvc.Components.getInstance(id)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in SplunkJS?&lt;/P&gt;

&lt;P&gt;Is there a reference for Splunk mvc library?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Dec 2014 12:09:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/SplunkJS-What-s-the-difference-between-get-and-getInstance/m-p/159501#M2167</guid>
      <dc:creator>marco_sulla</dc:creator>
      <dc:date>2014-12-16T12:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: SplunkJS: What's the difference between get() and getInstance()?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/SplunkJS-What-s-the-difference-between-get-and-getInstance/m-p/159502#M2168</link>
      <description>&lt;P&gt;With getInstance() you can also create the component if it does not exists. From &lt;CODE&gt;$SPLUNK_HOME/share/splunk/search_mrsparkle/exposed/js/splunkjs/mvc/registry.js&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/**
 * @param id                The id of the instance to return.
 * @param options           (Optional).
 * @param options.create    Whether to create a new token model with
 *                          the given name if the specified instance
 *                          does not exist.
 * @return                  The specified instance, or a falsy value
 *                          if the instance does not exist and
 *                          options.create is omitted or false.
 */
getInstance: function(id, options) {
    options = options || {};

    // If an instance with this id doesn't exist,
    // figure out whether we want to create one or not.
    if (!this.has(id)) {
        if (options.create) {
            this.registerInstance(id, this._createTokenModel(id));
        }
        else {
            console.error(this.createError("No instance with id: " + id));
        }
    }

    return this.get(id);
},
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Apr 2015 17:46:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/SplunkJS-What-s-the-difference-between-get-and-getInstance/m-p/159502#M2168</guid>
      <dc:creator>marco_sulla</dc:creator>
      <dc:date>2015-04-25T17:46:24Z</dc:date>
    </item>
  </channel>
</rss>

