Sha256: 255b03dc083313b1b5e37fc404265822eca6e78e3380b51ba75551aec2790941

Contents?: true

Size: 1009 Bytes

Versions: 2

Compression:

Stored size: 1009 Bytes

Contents

import Resolver from './resolver';
import resolve from '../resolve';

import createRecursiveResolver from './create_recursive_resolver';

class CurrentPageResolver extends Resolver {
  constructor(options, callback) {
    super(callback);

    this._subscribeToPageChange();
    this._pageResolver = resolve('page', {property: 'permaId'})(callback);
  }

  get(_, seed) {
    return this._pageResolver.get({
      permaId: this._currentParentPagePermaId(seed)
    }, seed);
  }

  dispose() {
    this._unsubscribeFromPageChange();
  }

  _currentParentPagePermaId(seed) {
    var currentPagePermaId = pageflow.slides.currentPage().page('getPermaId');
    return pageflow.entryData.getParentPagePermaIdByPagePermaId(currentPagePermaId);
  }

  _subscribeToPageChange() {
    pageflow.events.on('page:change', this._handleChange, this);
  }

  _unsubscribeFromPageChange() {
    pageflow.events.off('page:change', this._handleChange, this);
  }
};

export default createRecursiveResolver(CurrentPageResolver);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pageflow-react-0.1.1 js/src/resolvers/current_parent_page_resolver.js
pageflow-react-0.1.0 js/src/resolvers/current_parent_page_resolver.js