The Revealing Module Pattern is an updated Module Pattern where you define all of your functions and variables in the private scope and return an anonymous object at the end of the module along with pointers to both the private variables and functions you wish to reveal as public.
Questions tagged [revealing-module-pattern]
179 questions
0
votes
0 answers
Documenting revealing pattern nested in another function using JSDocs
I'm new to attempting to use JSDocs, and I've recently just learnt about closures, modules in javascript.
I'm trying to document my js file that has the following basic structure (there are actually many more parameters and methods). I've tried…

Rob G
- 140
- 1
- 11
0
votes
1 answer
Returning data resolved by XMLHttpRequest with module pattern function
I have problem combining javascript callbacks and revealing module pattern.
What I'm trying to do is to return the HTTP response text with the carsData.getCars() function method.
Basically what I want to do is:
return the data from…

Silvers
- 32
- 2
- 7
0
votes
1 answer
Revealing class pattern vs prototype method?
I've seen the revealing module pattern, as well as the prototype class pattern. I kind of adapted the two together into a revealing class pattern. I'm trying to figure out if there are any gotchas with this pattern, or things that wouldn't work. As…

wayofthefuture
- 8,339
- 7
- 36
- 53
0
votes
1 answer
Using the Revealing Module Pattern, why is this object changed?
Given the following code:
var House = function(x, y) {
var _posX;
var _posY;
function init(x,y) {
_posX = x;
_posY = y;
}
// Auto init
init(x, y);
// Public
return {
posX: _posX,
…

user3125591
- 113
- 5
- 13
0
votes
0 answers
Building a Javascript Grid framework: should I choose the Revealing pattern or prototypal inheritance on this situation?
I started using the revealing pattern and I'm starting to think if there isn't a better approach for this.....
var grid= (function(){
var grid='';
function init(gridOptions) {
cacheDom(gridOptions);
//this.bindEvents();
…

John
- 1,711
- 2
- 29
- 42
0
votes
2 answers
Difference between Revealing Module Pattern and simple Constructor
Googled but did not find appropriate resource to explain the difference between using Revealing Module Pattern and this keyword.
When using revealing module pattern I can have the below code :
var moduleRevealing = function() {
var talk =…

Shubh
- 6,693
- 9
- 48
- 83
0
votes
0 answers
Revealing module pattern with prototype
Te following code is fine:
var Pill = (function() {
var hideCheckPricesPill = function() {
$(HB.pillSearchBar.checkPrices).hide();
};
var hideAnyPill = function(pill) {
$(pill).hide();
};
var displaySearchBar =…

Aessandro
- 5,517
- 21
- 66
- 139
0
votes
1 answer
Difference between & usage of JavaScript & AngularJs Modules
The below code shows you a JavaScript Module (revealing pattern):
var module = (function(){
var _privateMethod = function(){
//code here
}
var publicMethod = function(){
//code here
}
return {
publicMethod:…

Skywalker
- 4,984
- 16
- 57
- 122
0
votes
0 answers
JSDoc for a special module pattern
I have a special JS revealing module pattern like in the example below and I am trying to document using JSDoc 3.
The situation is similar to this and this, but my constructor has arguments and there isn't a prototype root variable.
If I put @class…

fsmaia
- 1
- 2
0
votes
1 answer
knockout setting computed within javascript revealing module pattern
I am using knockout with revealing module pattern. I want to pass in an observable by reference and have its' value based on a computed. This issue is it is not getting passed into the pattern by reference...it seems like it is getting passed in…

David
- 3,047
- 4
- 45
- 79
0
votes
1 answer
revealing module pattern & variable scope -> public object undefined after async call returns
I have an Angular controller, which appeared to be working fine. I can console log the user variable inside of the service call, and it contains the correct data. However in my test, I can console log the controller and verify the user object is…

Kraken
- 5,043
- 3
- 25
- 46
0
votes
1 answer
Getting element ID from dynamic element using Revealing Module Pattern
I have a module that created some elements dynamically. Since they are created dynamically, I am having bind events using the static element $('#data-container) containing the dynamically created elements like so:
var $dataContainer =…

dericcain
- 2,182
- 7
- 30
- 52
0
votes
1 answer
Load settings from JSON file inside revealing module wih javascript
I have several different tools and each tool has many private and public functions. I use one JSON data file to store settings and data needed for the tools.
This because our editors that has no coding knowledge should be able to change the settings…

Mister No
- 1
- 1
0
votes
1 answer
Revealing Module Pattern variable problems
I am new to web development and I recently discovered the revealing module pattern. But I am having problems implementing it in to my JS.
var navigation = (function(){
//chache DOM
var $navBar = $('.navBar');
var $navBtn = $('.navBar…

BudBurriss
- 136
- 5
0
votes
2 answers
JavaScript Revealing Module Pattern global variable is undefined
I'm trying to use the Revealing Module Pattern to scope the JavaScript on my page so that I don't pollute the global namespace.